Class: CityGrid::Abstraction::SuperHash
- Inherits:
-
Hash
- Object
- Hash
- CityGrid::Abstraction::SuperHash
show all
- Defined in:
- lib/citygrid/abstraction/super_hash.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/citygrid/abstraction/super_hash.rb', line 12
def method_missing sym, *args, &block
val = self[sym] || self[sym.to_s]
if val.is_a? Hash
SuperHash.new val
elsif val.is_a? Array
SuperArray.new val
elsif keys.include?(sym) || keys.include?(sym.to_s)
val
else
super
end
end
|
Class Method Details
.new(attrs) ⇒ Object
8
9
10
|
# File 'lib/citygrid/abstraction/super_hash.rb', line 8
def self.new attrs
self[attrs]
end
|