Class: ForwardableContentHashBinder
- Inherits:
-
Object
- Object
- ForwardableContentHashBinder
- Defined in:
- lib/forwardable_content_hash_binder.rb
Instance Attribute Summary collapse
-
#content_hash ⇒ Object
readonly
Returns the value of attribute content_hash.
Instance Method Summary collapse
- #[]=(key, value) ⇒ Object
- #get_binding ⇒ Object
-
#initialize(content_hash) ⇒ ForwardableContentHashBinder
constructor
A new instance of ForwardableContentHashBinder.
- #method_missing(method, *args) ⇒ Object
Constructor Details
#initialize(content_hash) ⇒ ForwardableContentHashBinder
Returns a new instance of ForwardableContentHashBinder.
5 6 7 |
# File 'lib/forwardable_content_hash_binder.rb', line 5 def initialize(content_hash) @content_hash = content_hash end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/forwardable_content_hash_binder.rb', line 9 def method_missing(method, *args) super(method, args) unless @content_hash[method.to_s] value = @content_hash[method.to_s] return value unless value.kind_of? Proc value.call end |
Instance Attribute Details
#content_hash ⇒ Object (readonly)
Returns the value of attribute content_hash.
3 4 5 |
# File 'lib/forwardable_content_hash_binder.rb', line 3 def content_hash @content_hash end |
Instance Method Details
#[]=(key, value) ⇒ Object
16 17 18 |
# File 'lib/forwardable_content_hash_binder.rb', line 16 def []=(key,value) content_hash[key] = value end |
#get_binding ⇒ Object
20 21 22 |
# File 'lib/forwardable_content_hash_binder.rb', line 20 def get_binding binding end |