Class: Redshift::Client::Configuration
- Inherits:
-
Object
- Object
- Redshift::Client::Configuration
- Defined in:
- lib/redshift/client/configuration.rb
Instance Attribute Summary collapse
-
#dbname ⇒ Object
readonly
Returns the value of attribute dbname.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(host, port, user, password, dbname) ⇒ Configuration
constructor
A new instance of Configuration.
- #to_hash ⇒ Object
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
#dbname ⇒ Object (readonly)
Returns the value of attribute dbname.
4 5 6 |
# File 'lib/redshift/client/configuration.rb', line 4 def dbname @dbname end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
4 5 6 |
# File 'lib/redshift/client/configuration.rb', line 4 def host @host end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
4 5 6 |
# File 'lib/redshift/client/configuration.rb', line 4 def password @password end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
4 5 6 |
# File 'lib/redshift/client/configuration.rb', line 4 def port @port end |
#user ⇒ Object (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.) end |
Instance Method Details
#to_hash ⇒ Object
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 |