Module: Lazier::Hash
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/lazier/hash.rb
Overview
Extensions for Hash objects.
Instance Method Summary collapse
-
#method_missing(method, *args, &block) ⇒ Object
This is called when the user access a member using dotted notation.
-
#respond_to?(method) ⇒ Boolean
This is called when the user access a member using dotted notation.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
This is called when the user access a member using dotted notation.
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/lazier/hash.rb', line 18 def method_missing(method, *args, &block) rv = nil if self.has_key?(method.to_sym) then rv = self[method.to_sym] elsif self.has_key?(method.to_s) then rv = self[method.to_s] else rv = ::Hash.method_missing(method, *args, &block) end rv end |
Instance Method Details
#respond_to?(method) ⇒ Boolean
This is called when the user access a member using dotted notation.
36 37 38 |
# File 'lib/lazier/hash.rb', line 36 def respond_to?(method) (self.has_key?(method.to_sym) || self.has_key?(method.to_s)) ? true : ::Hash.respond_to?(method) end |