Class: Canpe::TemplateBindingReflector
- Inherits:
-
Object
- Object
- Canpe::TemplateBindingReflector
- Defined in:
- lib/canpe/template_binding_reflector.rb
Instance Attribute Summary collapse
-
#call_list ⇒ Object
readonly
Returns the value of attribute call_list.
Instance Method Summary collapse
-
#initialize(call_list = []) ⇒ TemplateBindingReflector
constructor
A new instance of TemplateBindingReflector.
- #method_missing(method, *args) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(call_list = []) ⇒ TemplateBindingReflector
Returns a new instance of TemplateBindingReflector.
5 6 7 |
# File 'lib/canpe/template_binding_reflector.rb', line 5 def initialize(call_list = []) @call_list = call_list end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
9 10 11 |
# File 'lib/canpe/template_binding_reflector.rb', line 9 def method_missing(method, *args) Reflector.new(call_list + [{ method: method, args: args }]) end |
Instance Attribute Details
#call_list ⇒ Object (readonly)
Returns the value of attribute call_list.
3 4 5 |
# File 'lib/canpe/template_binding_reflector.rb', line 3 def call_list @call_list end |
Instance Method Details
#to_s ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/canpe/template_binding_reflector.rb', line 13 def to_s method_chain = call_list.map do |hash| method_call = "#{hash[:method].to_s}" method_call += "(#{hash[:args].join(', ')})" if hash[:args].size > 0 method_call end.join '.' "Error: #{method_chain}" end |