Module: Knodes::Configuration
- Included in:
- Knodes
- Defined in:
- lib/knodes/configuration.rb
Constant Summary collapse
- VALID_OPTIONS_KEYS =
[ :customer_id, :customer_secret, :endpoint, :adapter, :format, :proxy, :user_agent ].freeze
- DEFAULT_ADAPTER =
The adapter that will be used to connect if none is set The default faraday adapter is Net::HTTP.
Faraday.default_adapter
- DEFAULT_CUSTOMER_ID =
By default, don’t set a customer ID
nil- DEFAULT_CUSTOMER_SECRET =
By default, don’t set a customer secret
nil- DEFAULT_ENDPOINT =
The endpoint that will be used to connect if none is set
'https://api.knod.es/'- DEFAULT_PROXY =
By default, don’t use a proxy server
nil- DEFAULT_FORMAT =
The response format appended to the path and sent in the ‘Accept’ header if none is set JSON is the only available format at this time
:json- DEFAULT_USER_AGENT =
The user agent that will be sent to the API endpoint if none is set
'KnodesRubyClient/1.0'
Class Method Summary collapse
-
.extended(base) ⇒ Object
When this module is extended, set all configuration options to their default values.
Instance Method Summary collapse
-
#configure {|_self| ... } ⇒ Object
allow config values to be set in a block.
-
#options ⇒ Object
return hash of options.
- #reset ⇒ Object
Class Method Details
.extended(base) ⇒ Object
When this module is extended, set all configuration options to their default values
53 54 55 |
# File 'lib/knodes/configuration.rb', line 53 def self.extended(base) base.reset end |
Instance Method Details
#configure {|_self| ... } ⇒ Object
allow config values to be set in a block
41 42 43 |
# File 'lib/knodes/configuration.rb', line 41 def configure yield self end |
#options ⇒ Object
return hash of options
46 47 48 49 50 |
# File 'lib/knodes/configuration.rb', line 46 def VALID_OPTIONS_KEYS.inject({}) do |option, key| option.merge!(key => send(key)) end end |
#reset ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/knodes/configuration.rb', line 57 def reset self.adapter = DEFAULT_ADAPTER self.customer_id = DEFAULT_CUSTOMER_ID self.customer_secret = DEFAULT_CUSTOMER_SECRET self.endpoint = DEFAULT_ENDPOINT self.format = DEFAULT_FORMAT self.proxy = DEFAULT_PROXY self.user_agent = DEFAULT_USER_AGENT end |