Module: Timepad::Config

Included in:
Timepad
Defined in:
lib/timepad/config.rb

Constant Summary collapse

DEFAULT_ENDPOINT =
'http://timepad.ru/api/'
DEFAULT_ID =
nil
DEFAULT_KEY =
nil
VALID_OPTIONS_KEYS =
[
  :id,
  :key,
  :endpoint
]

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



18
19
20
# File 'lib/timepad/config.rb', line 18

def self.extended(base)
  base.reset
end

Instance Method Details

#configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



22
23
24
25
# File 'lib/timepad/config.rb', line 22

def configure
  yield self
  self
end

#optionsHash

Create a hash of options and their values

Returns:

  • (Hash)


30
31
32
33
34
# File 'lib/timepad/config.rb', line 30

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

#resetObject



36
37
38
39
40
41
# File 'lib/timepad/config.rb', line 36

def reset
  self.id       = DEFAULT_ID
  self.key      = DEFAULT_KEY
  self.endpoint = DEFAULT_ENDPOINT
  self
end