Class: Atlas::Configuration
- Inherits:
-
Object
- Object
- Atlas::Configuration
- Defined in:
- lib/atlas/configuration.rb
Overview
Configuration handling for Atlas.
Instance Attribute Summary collapse
-
#token ⇒ Object
Access token for Atlas.
Instance Method Summary collapse
- #access_token=(access_token) ⇒ Object
-
#initialize(opts = {}) ⇒ Configuration
constructor
Create a new Configuration instance.
-
#to_h ⇒ Object
Hash representation of the configuration object.
-
#to_s ⇒ Object
String representation of the configuration.
Constructor Details
#initialize(opts = {}) ⇒ Configuration
Create a new Configuration instance
This also allows providing a hash of configuration values, which calls the accessor methods to full in the values.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/atlas/configuration.rb', line 11 def initialize(opts = {}) opts.each do |key, value| if key.eql?(:access_token) key = "token" warn "WARNING: Setting the `:access_token` option is " \ "deprecated, use `:token` instead" end send("#{key}=".to_sym, value) end end |
Instance Attribute Details
#token ⇒ Object
Access token for Atlas
5 6 7 |
# File 'lib/atlas/configuration.rb', line 5 def token @token end |
Instance Method Details
#access_token=(access_token) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/atlas/configuration.rb', line 34 def access_token=(access_token) warn "WARNING: Setting the `:access_token` option is " \ "deprecated, use `:token` instead" @token = access_token end |
#to_h ⇒ Object
Hash representation of the configuration object.
24 25 26 |
# File 'lib/atlas/configuration.rb', line 24 def to_h { token: @token } end |
#to_s ⇒ Object
String representation of the configuration.
29 30 31 32 |
# File 'lib/atlas/configuration.rb', line 29 def to_s objects = to_h.collect { |k, v| "#{k}=#{v}" }.join(' ') "#<#{self.class.name}:#{object_id} #{objects}" end |