Class: Stealth::Configuration

Inherits:
Hash
  • Object
show all
Defined in:
lib/stealth/configuration.rb

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Configuration

Returns a new instance of Configuration.



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

def initialize(hash)
  hash.each do |k, v|
    self[k] = store(v)
  end

  self
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/stealth/configuration.rb', line 17

def method_missing(method, *args)
  key = create_config_attribute(method)

  if setter?(method)
    self[key] = args.first
  else
    super(method, args) && return unless key?(key)
    self[key]
  end
end