Class: Nucleo::Configuration
- Inherits:
-
Object
- Object
- Nucleo::Configuration
- Defined in:
- lib/nucleo/configuration.rb
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
-
#api_host ⇒ Object
Connection.
-
#cache_logger ⇒ Object
Returns the value of attribute cache_logger.
-
#connection_options ⇒ Hash
The final set of connection options.
-
#content_type ⇒ Object
Returns the value of attribute content_type.
-
#detailed_logger ⇒ Object
Logging.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#media_type ⇒ Object
Returns the value of attribute media_type.
-
#request_logger ⇒ Object
Returns the value of attribute request_logger.
-
#user_agent ⇒ Object
Request.
Class Method Summary collapse
-
.keys ⇒ Array<Symbol>
Returns the set of allowed configuration options.
Instance Method Summary collapse
-
#configure {|_self| ... } ⇒ Nucleo::Configuration
Allows you to configure the object after it’s been initialized.
-
#initialize(attributes = {}) ⇒ Nucleo::Configuration
constructor
Create a new instance of the Configuration Object.
-
#reset! ⇒ Nucleo::Configuration
(also: #setup)
Allows you to reset your configuration back to the default state.
Constructor Details
#initialize(attributes = {}) ⇒ Nucleo::Configuration
Create a new instance of the Configuration Object
45 46 47 48 49 |
# File 'lib/nucleo/configuration.rb', line 45 def initialize(attributes={}) self.class.keys.each do |key| instance_variable_set(:"@#{key}", (attributes[key] || Nucleo::Configurations::Default.[key])) end end |
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
7 8 9 |
# File 'lib/nucleo/configuration.rb', line 7 def access_token @access_token end |
#api_host ⇒ Object
Connection
6 7 8 |
# File 'lib/nucleo/configuration.rb', line 6 def api_host @api_host end |
#cache_logger ⇒ Object
Returns the value of attribute cache_logger.
18 19 20 |
# File 'lib/nucleo/configuration.rb', line 18 def cache_logger @cache_logger end |
#connection_options ⇒ Hash
The final set of connection options
54 55 56 |
# File 'lib/nucleo/configuration.rb', line 54 def @connection_options end |
#content_type ⇒ Object
Returns the value of attribute content_type.
13 14 15 |
# File 'lib/nucleo/configuration.rb', line 13 def content_type @content_type end |
#detailed_logger ⇒ Object
Logging
16 17 18 |
# File 'lib/nucleo/configuration.rb', line 16 def detailed_logger @detailed_logger end |
#logger ⇒ Object
Returns the value of attribute logger.
19 20 21 |
# File 'lib/nucleo/configuration.rb', line 19 def logger @logger end |
#media_type ⇒ Object
Returns the value of attribute media_type.
12 13 14 |
# File 'lib/nucleo/configuration.rb', line 12 def media_type @media_type end |
#request_logger ⇒ Object
Returns the value of attribute request_logger.
17 18 19 |
# File 'lib/nucleo/configuration.rb', line 17 def request_logger @request_logger end |
#user_agent ⇒ Object
Request
11 12 13 |
# File 'lib/nucleo/configuration.rb', line 11 def user_agent @user_agent end |
Class Method Details
.keys ⇒ Array<Symbol>
Returns the set of allowed configuration options
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/nucleo/configuration.rb', line 25 def self.keys @keys ||= [ :api_host, :access_token, :connection_options, :user_agent, :media_type, :content_type, :request_logger, :detailed_logger, :cache_logger, :logger ] end |
Instance Method Details
#configure {|_self| ... } ⇒ Nucleo::Configuration
Allows you to configure the object after it’s been initialized.
68 69 70 |
# File 'lib/nucleo/configuration.rb', line 68 def configure(&block) yield(self) end |
#reset! ⇒ Nucleo::Configuration Also known as: setup
Allows you to reset your configuration back to the default state.
76 77 78 79 80 |
# File 'lib/nucleo/configuration.rb', line 76 def reset! self.class.keys.each do |key| instance_variable_set(:"@#{key}", Nucleo::Configurations::Default.[key]) end end |