Class: David::AppConfig

Inherits:
Hash
  • Object
show all
Defined in:
lib/david/app_config.rb

Constant Summary collapse

DEFAULT_OPTIONS =
{
  :Block => true,
  :CBOR => false,
  :DefaultFormat => 'application/json',
  :Host => ENV['RACK_ENV'] == 'development' ? '::1' : '::',
  :Log => nil,
  :MinimalMapping => false,
  :Multicast => true,
  :MulticastGroups => ['ff02::fd', 'ff05::fd'],
  :Observe => true,
  :Port => ::CoAP::PORT
}

Instance Method Summary collapse

Constructor Details

#initialize(hash = {}) ⇒ AppConfig

Returns a new instance of AppConfig.


16
17
18
19
20
21
22
23
# File 'lib/david/app_config.rb', line 16

def initialize(hash = {})
  self.merge!(DEFAULT_OPTIONS)
  self.merge!(hash)

  (self.keys & DEFAULT_OPTIONS.keys).each do |key|
    optionize!(key)
  end
end