Module: WorldTimeEngine::Configurable

Included in:
WorldTimeEngine, Client
Defined in:
lib/worldtimeengine/configurable.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#api_key=(value) ⇒ Object (writeonly)

Sets the attribute api_key

Parameters:

  • value

    the value to set the attribute api_key to.



3
4
5
# File 'lib/worldtimeengine/configurable.rb', line 3

def api_key=(value)
  @api_key = value
end

#endpointObject

Returns the value of attribute endpoint.



5
6
7
# File 'lib/worldtimeengine/configurable.rb', line 5

def endpoint
  @endpoint
end

#timeout=(value) ⇒ Object (writeonly)

Sets the attribute timeout

Parameters:

  • value

    the value to set the attribute timeout to.



4
5
6
# File 'lib/worldtimeengine/configurable.rb', line 4

def timeout=(value)
  @timeout = value
end

Class Method Details

.keysObject



9
10
11
12
13
14
15
# File 'lib/worldtimeengine/configurable.rb', line 9

def keys
  @keys ||= [
    :api_key,
    :timeout,
    :endpoint
  ]
end

Instance Method Details

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

Convenience method to allow configuration options to be set in a block

Yields:

  • (_self)

Yield Parameters:



20
21
22
23
# File 'lib/worldtimeengine/configurable.rb', line 20

def configure
  yield self
  self
end

#credentials?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/worldtimeengine/configurable.rb', line 26

def credentials?
  credentials.values.all?
end

#reset!Object Also known as: setup



30
31
32
33
34
35
# File 'lib/worldtimeengine/configurable.rb', line 30

def reset!
  @api_key = nil
  @endpoint = 'http://worldtimeengine.com'
  @timeout = 10 # seconds
  self
end