Module: Lazier::Hash
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/lazier/hash.rb
Overview
Extensions for Hash objects.
Instance Method Summary (collapse)
-
- (Object) method_missing(method, *args, &block)
This is called when the user access a member using dotted notation.
-
- (Boolean) respond_to?(method)
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
- (Object) method_missing(method, *args, &block)
This is called when the user access a member using dotted notation.
18 19 20 21 22 23 24 25 26 |
# File 'lib/lazier/hash.rb', line 18 def method_missing(method, *args, &block) if self.has_key?(method.to_sym) then self[method.to_sym] elsif self.has_key?(method.to_s) then self[method.to_s] else ::Hash.method_missing(method, *args, &block) end end |
Instance Method Details
- (Boolean) respond_to?(method)
This is called when the user access a member using dotted notation.
32 33 34 |
# File 'lib/lazier/hash.rb', line 32 def respond_to?(method) (self.has_key?(method.to_sym) || self.has_key?(method.to_s)) ? true : ::Hash.respond_to?(method) end |