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.



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

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.



6
7
8
# File 'lib/redshift/client/configuration.rb', line 6

def dbname
  @dbname
end

#hostObject (readonly)

Returns the value of attribute host.



6
7
8
# File 'lib/redshift/client/configuration.rb', line 6

def host
  @host
end

#passwordObject (readonly)

Returns the value of attribute password.



6
7
8
# File 'lib/redshift/client/configuration.rb', line 6

def password
  @password
end

#portObject (readonly)

Returns the value of attribute port.



6
7
8
# File 'lib/redshift/client/configuration.rb', line 6

def port
  @port
end

#userObject (readonly)

Returns the value of attribute user.



6
7
8
# File 'lib/redshift/client/configuration.rb', line 6

def user
  @user
end

Class Method Details

.resolve(config = {}) ⇒ Object



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

def self.resolve(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

#paramsObject



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

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