Module: ESV::Config
- Included in:
- ESV
- Defined in:
- lib/esv_api/config.rb
Overview
Defines constants and methods related to configuration
Constant Summary collapse
- DEFAULT_API_KEY =
The API Key if none is set
nil- DEFAULT_ENDPOINT =
The endpoint that will be used to connect if none is set
'http://www.esvapi.org/v2/rest/'- DEFAULT_USER_AGENT =
The value sent in the ‘User-Agent’ header if none is set
"esv_api Ruby Gem #{ESV::Version}"- VALID_OPTIONS_KEYS =
An array of valid keys in the options hash when configuring a Twitter::Client
[ :api_key, :endpoint, :user_agent, :should_cache ]
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
Convenience method to allow configuration options to be set in a block.
-
#options ⇒ Object
Create a hash of options and their values.
-
#reset ⇒ Object
Reset all configuration options to defaults.
Class Method Details
.extended(base) ⇒ Object
When this module is extended, set all configuration options to their default values
27 28 29 |
# File 'lib/esv_api/config.rb', line 27 def self.extended(base) base.reset end |
Instance Method Details
#configure {|_self| ... } ⇒ Object
Convenience method to allow configuration options to be set in a block
32 33 34 35 |
# File 'lib/esv_api/config.rb', line 32 def configure yield self self end |
#options ⇒ Object
Create a hash of options and their values
38 39 40 41 42 |
# File 'lib/esv_api/config.rb', line 38 def = {} VALID_OPTIONS_KEYS.each{|k| [k] = send(k)} end |
#reset ⇒ Object
Reset all configuration options to defaults
45 46 47 48 49 50 51 |
# File 'lib/esv_api/config.rb', line 45 def reset self.api_key = DEFAULT_API_KEY self.endpoint = DEFAULT_ENDPOINT self.user_agent = DEFAULT_USER_AGENT self.should_cache = true self end |