Module: Rpub::HashDelegation
- Included in:
- Book
- Defined in:
- lib/rpub/hash_delegation.rb
Overview
Delegate missing methods to keys in a Hash atribute on the current object.
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
18 19 20 21 |
# File 'lib/rpub/hash_delegation.rb', line 18 def method_missing(m, *args, &block) return super unless respond_to? m delegated_hash.fetch m.to_s end |
Instance Method Details
#respond_to?(m) ⇒ Boolean
14 15 16 |
# File 'lib/rpub/hash_delegation.rb', line 14 def respond_to?(m) super || delegated_hash.has_key?(m.to_s) end |