Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/hash.rb
Class Attribute Summary collapse
-
.use_dot_syntax ⇒ Object
Returns the value of attribute use_dot_syntax.
Instance Attribute Summary collapse
-
#use_dot_syntax ⇒ Object
Returns the value of attribute use_dot_syntax.
Instance Method Summary collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/hash.rb', line 14 def method_missing(method, *args) return super(method, *args) unless to_dot? prop = create_prop(method) if self[prop].nil? self[prop] = 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 |
Class Attribute Details
.use_dot_syntax ⇒ Object
Returns the value of attribute use_dot_syntax.
3 4 5 |
# File 'lib/hash.rb', line 3 def use_dot_syntax @use_dot_syntax end |
Instance Attribute Details
#use_dot_syntax ⇒ Object
Returns the value of attribute use_dot_syntax.
6 7 8 |
# File 'lib/hash.rb', line 6 def use_dot_syntax @use_dot_syntax end |
Instance Method Details
#to_dot ⇒ Object
8 9 10 11 12 |
# File 'lib/hash.rb', line 8 def to_dot dotify_hash(self) self end |