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

Instance Method Summary collapse

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

Yields:

  • (_self)

Yield Parameters:



23
24
25
26
# File 'lib/taskrabbit/config.rb', line 23

def configure
  yield self
  self
end

#optionsObject

Create a hash of options and their values



29
30
31
32
33
# File 'lib/taskrabbit/config.rb', line 29

def options
  {}.tap do |options|
    VALID_OPTIONS_KEYS.each{|k| options[k] = send(k)}
  end
end

#resetObject

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