Module: Taskrabbit::Config
- Included in:
- Taskrabbit
- Defined in:
- lib/taskrabbit/config.rb
Constant Summary collapse
- DEFAULT_BASE_URI =
'https://www.taskrabbit.com'- DEFAULT_END_POINT =
'api/v1'- DEFAULT_API_SECRET =
nil- DEFAULT_API_KEY =
nil- VALID_OPTIONS_KEYS =
[ :base_uri, :api_key, :api_secret, :endpoint ]
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
18 19 20 |
# File 'lib/taskrabbit/config.rb', line 18 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
23 24 25 26 |
# File 'lib/taskrabbit/config.rb', line 23 def configure yield self self end |
#options ⇒ Object
Create a hash of options and their values
29 30 31 32 33 |
# File 'lib/taskrabbit/config.rb', line 29 def {}.tap do || VALID_OPTIONS_KEYS.each{|k| [k] = send(k)} end end |
#reset ⇒ Object
Reset all configuration options to defaults
36 37 38 39 40 41 42 43 |
# File 'lib/taskrabbit/config.rb', line 36 def reset self.tap do |c| c.base_uri = DEFAULT_BASE_URI c.endpoint = DEFAULT_END_POINT c.api_secret = DEFAULT_API_SECRET c.api_key = DEFAULT_API_KEY end end |