Class: Hash
Instance Method Summary collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 |
# File 'lib/rubyhelpers/hash.rb', line 2 def method_missing(sym, *args) method = sym.to_s if method[-1..-1] == "=" self[method[0..-2]] = args[0] elsif method[-8..-1] == "_exists?" self.has_key?(method[0..-9]) else raise NoMethodError unless self.has_key?(method) self[method] end end |