Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/hash_dot.rb
Instance Method Summary collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/hash_dot.rb', line 15 def method_missing(method, *args) prop = create_prop(method) if self[prop].nil? self[prop] = self[prop.to_s] self.delete(prop.to_s) end super(method, args) and return if self[prop].nil? if setter?(method) self[prop] = args.first else self[prop] end end |