Class: Redshift::Client::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/redshift/client/configuration.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, port, user, password, dbname) ⇒ Configuration

Returns a new instance of Configuration.



17
18
19
20
21
22
23
# File 'lib/redshift/client/configuration.rb', line 17

def initialize(host, port, user, password, dbname)
  @host = host
  @port = port || 5439
  @user = user
  @password = password
  @dbname = dbname
end

Instance Attribute Details

#dbnameObject (readonly)

Returns the value of attribute dbname.



4
5
6
# File 'lib/redshift/client/configuration.rb', line 4

def dbname
  @dbname
end

#hostObject (readonly)

Returns the value of attribute host.



4
5
6
# File 'lib/redshift/client/configuration.rb', line 4

def host
  @host
end

#passwordObject (readonly)

Returns the value of attribute password.



4
5
6
# File 'lib/redshift/client/configuration.rb', line 4

def password
  @password
end

#portObject (readonly)

Returns the value of attribute port.



4
5
6
# File 'lib/redshift/client/configuration.rb', line 4

def port
  @port
end

#userObject (readonly)

Returns the value of attribute user.



4
5
6
# File 'lib/redshift/client/configuration.rb', line 4

def user
  @user
end

Class Method Details

.parse(config) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/redshift/client/configuration.rb', line 6

def self.parse(config)
  if config.empty?
    url = URI.parse(ENV["REDSHIFT_URL"])
    self.new(url.host, url.port, url.user, url.password, url.path[1..-1])
  else
    self.new(config[:host], config[:port], config[:user], config[:password], config[:dbname])
  end
rescue => e
  raise ConfigurationError.new(e.message)
end

Instance Method Details

#to_hashObject



25
26
27
28
29
30
31
32
33
# File 'lib/redshift/client/configuration.rb', line 25

def to_hash
  {
    host: @host,
    port: @port,
    user: @user,
    password: @password,
    dbname: @dbname
  }
end