Class: Stove::Mash

Inherits:
Hash
  • Object
show all
Defined in:
lib/stove/mash.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args, &block) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/stove/mash.rb', line 3

def method_missing(m, *args, &block)
  if has_key?(m.to_sym)
    self[m.to_sym]
  elsif has_key?(m.to_s)
    self[m.to_s]
  else
    super
  end
end

Instance Method Details

#methods(include_private = false) ⇒ Object



13
14
15
# File 'lib/stove/mash.rb', line 13

def methods(include_private = false)
  super + self.keys.map(&:to_sym)
end

#respond_to?(m, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


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

def respond_to?(m, include_private = false)
  if has_key?(m.to_sym) || has_key?(m.to_s)
    true
  else
    super
  end
end