Module: Open311::Configuration

Included in:
Open311
Defined in:
lib/open311/configuration.rb

Constant Summary collapse

VALID_OPTIONS_KEYS =
[:adapter, :api_key, :endpoint, :format, :jurisdiction, :proxy, :user_agent].freeze
VALID_FORMATS =
[:json, :xml].freeze
DEFAULT_ADAPTER =
Faraday.default_adapter.freeze
DEFAULT_API_KEY =
nil.freeze
DEFAULT_ENDPOINT =
nil.freeze
DEFAULT_FORMAT =
:json.freeze
DEFAULT_JURISDICTION =
nil.freeze
DEFAULT_PROXY =
nil.freeze
DEFAULT_USER_AGENT =
"Open311 Ruby Gem #{Open311::VERSION}".freeze

Instance Method Summary collapse

Instance Method Details

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

Yields:

  • (_self)

Yield Parameters:


23
24
25
# File 'lib/open311/configuration.rb', line 23

def configure
  yield self
end

#optionsObject


27
28
29
# File 'lib/open311/configuration.rb', line 27

def options
  VALID_OPTIONS_KEYS.inject({}){|o,k| o.merge!(k => send(k)) }
end

#resetObject


31
32
33
34
35
36
37
38
39
# File 'lib/open311/configuration.rb', line 31

def reset
  self.adapter      = DEFAULT_ADAPTER
  self.api_key      = DEFAULT_API_KEY
  self.endpoint     = DEFAULT_ENDPOINT
  self.format       = DEFAULT_FORMAT
  self.jurisdiction = DEFAULT_JURISDICTION
  self.proxy        = DEFAULT_PROXY
  self.user_agent   = DEFAULT_USER_AGENT
end