Class: Hash
- Inherits:
-
Object
show all
- Defined in:
- lib/cxxproject/ext/hash.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
2
3
4
5
6
7
8
|
# File 'lib/cxxproject/ext/hash.rb', line 2
def method_missing(m, *args, &block)
if m.to_s =~ /(.*)=$/
self[$1] = args[0]
else
fetch(m.to_s, nil)
end
end
|
Instance Method Details
#recursive_merge(h) ⇒ Object
9
10
11
|
# File 'lib/cxxproject/ext/hash.rb', line 9
def recursive_merge(h)
self.merge!(h) {|key, _old, _new| if _old.class == Hash then _old.recursive_merge(_new) else _new end }
end
|