Class: Canpe::TemplateBindingReflector

Inherits:
Object
  • Object
show all
Defined in:
lib/canpe/template_binding_reflector.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_listObject (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_sObject



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