Class: Hashdown::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/hashdown/cache.rb

Instance Method Summary collapse

Constructor Details

#initialize(hash = {}) ⇒ Config

Returns a new instance of Config.



29
30
31
# File 'lib/hashdown/cache.rb', line 29

def initialize(hash={})
  @data = hash
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_id, *args) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/hashdown/cache.rb', line 33

def method_missing(method_id, *args)
  if method_id.to_s =~ /^(\w*)=$/
    @data[$1.to_sym] = args.first
  elsif method_id.to_s =~ /^(\w*)\?$/
    @data.has_key?($1.to_sym)
  else
    if @data.has_key?(method_id)
      @data[method_id]
    else
      super
    end
  end
end