Module: DulyNoted::Configuration

Extended by:
Configuration
Included in:
DulyNoted, Configuration
Defined in:
lib/duly_noted/configuration.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/duly_noted/configuration.rb', line 25

def method_missing(sym, *args)
  if sym.to_s =~ /(.+)=$/
    self[$1] = args.first
  else
    self[sym]
  end
end

Instance Method Details

#[](key) ⇒ Object



13
14
15
# File 'lib/duly_noted/configuration.rb', line 13

def [](key)
  @data[key.to_sym]
end

#[]=(key, value) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/duly_noted/configuration.rb', line 17

def []=(key, value)
  if value.class == Hash
    @data[key.to_sym] = Config.new(value)
  else
    @data[key.to_sym] = value
  end
end

#update!(data) ⇒ Object



7
8
9
10
11
# File 'lib/duly_noted/configuration.rb', line 7

def update!(data)
  data.each do |key, value|
    self[key] = value
  end
end