Class: ERBReflective
- Inherits:
-
ERB
- Object
- ERB
- ERBReflective
- Defined in:
- lib/erb_reflective.rb
Overview
Override some ERB behaviour to make it reflect methods supported by an object that is passed to it
Instance Method Summary collapse
- #method_missing(meth, *args, &block) ⇒ Object
- #respond_to_missing?(meth) ⇒ Boolean
-
#result(other_object) ⇒ Object
Simply store the object reference passed in then call the superclass behaviour with our binding instead.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
15 16 17 18 |
# File 'lib/erb_reflective.rb', line 15 def method_missing(meth, *args, &block) super unless respond_to_missing? meth @other_object&.send(meth, *args, &block) end |
Instance Method Details
#respond_to_missing?(meth) ⇒ Boolean
20 21 22 |
# File 'lib/erb_reflective.rb', line 20 def respond_to_missing?(meth) @other_object&.respond_to? meth end |
#result(other_object) ⇒ Object
Simply store the object reference passed in then call the superclass behaviour with our binding instead
10 11 12 13 |
# File 'lib/erb_reflective.rb', line 10 def result(other_object) @other_object = other_object super(binding) end |