Module: DPN::Client::Agent::Configuration
- Included in:
- DPN::Client::Agent
- Defined in:
- lib/dpn/client/agent/configuration.rb
Defined Under Namespace
Classes: NullLogger
Constant Summary collapse
- @@keys =
[ :api_root, :auth_token, :per_page, :user_agent, :logger ]
- @@defaults =
{ api_root: nil.freeze, auth_token: nil.freeze, per_page: 25.freeze, user_agent: "dpn-client".freeze }.freeze
Instance Attribute Summary collapse
-
#api_root ⇒ Object
Returns the value of attribute api_root.
-
#auth_token ⇒ Object
Returns the value of attribute auth_token.
- #logger ⇒ Object
-
#per_page ⇒ Object
Returns the value of attribute per_page.
-
#user_agent ⇒ Object
Returns the value of attribute user_agent.
Instance Method Summary collapse
- #api_ver ⇒ Object
- #base_url ⇒ Object
-
#configure(options_hash = {}) ⇒ Object
Apply the options hash to the configuration.
-
#reset ⇒ Object
(also: #setup)
Reset to default values.
Instance Attribute Details
#api_root ⇒ Object
Returns the value of attribute api_root.
25 26 27 |
# File 'lib/dpn/client/agent/configuration.rb', line 25 def api_root @api_root end |
#auth_token ⇒ Object
Returns the value of attribute auth_token.
25 26 27 |
# File 'lib/dpn/client/agent/configuration.rb', line 25 def auth_token @auth_token end |
#logger ⇒ Object
61 62 63 |
# File 'lib/dpn/client/agent/configuration.rb', line 61 def logger @logger ||= NullLogger.new end |
#per_page ⇒ Object
Returns the value of attribute per_page.
25 26 27 |
# File 'lib/dpn/client/agent/configuration.rb', line 25 def per_page @per_page end |
#user_agent ⇒ Object
Returns the value of attribute user_agent.
25 26 27 |
# File 'lib/dpn/client/agent/configuration.rb', line 25 def user_agent @user_agent end |
Instance Method Details
#api_ver ⇒ Object
29 30 31 |
# File 'lib/dpn/client/agent/configuration.rb', line 29 def api_ver @api_ver ||= "api-v#{DPN::Client.api_version}" end |
#base_url ⇒ Object
33 34 35 |
# File 'lib/dpn/client/agent/configuration.rb', line 33 def base_url @api_root end |
#configure(options_hash = {}) ⇒ Object
Apply the options hash to the configuration
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/dpn/client/agent/configuration.rb', line 38 def configure( = {}) keys.each do |key| if [key] instance_variable_set(:"@#{key}", [key]) end end if block_given? yield self end return self end |
#reset ⇒ Object Also known as: setup
Reset to default values
52 53 54 55 56 57 |
# File 'lib/dpn/client/agent/configuration.rb', line 52 def reset keys.each do |key| instance_variable_set(:"@#{key}", defaults[key]) self end end |