Class: AppMap::Handler::Rails::Template::TemplateCall

Inherits:
Event::MethodEvent show all
Defined in:
lib/appmap/handler/rails/template.rb

Overview

TemplateCall is a type of function call which is specialized to view template rendering. Since there isn’t really a perfect method in Rails to hook, this one is synthesized from the available information.

Constant Summary

Constants inherited from Event::MethodEvent

Event::MethodEvent::LIMIT

Instance Attribute Summary collapse

Attributes inherited from Event::MethodEventStruct

#event, #id, #thread_id

Instance Method Summary collapse

Methods inherited from Event::MethodEvent

best_class_name, build_from_invocation, custom_display_string, default_display_string, display_string, object_properties

Constructor Details

#initialize(render_instance) ⇒ TemplateCall

Returns a new instance of TemplateCall.



61
62
63
64
65
66
# File 'lib/appmap/handler/rails/template.rb', line 61

def initialize(render_instance)
  super :call
  
  AppMap::Event::MethodEvent.build_from_invocation(:call, event: self)
  @render_instance = render_instance
end

Instance Attribute Details

#pathObject

Path to the view template.



59
60
61
# File 'lib/appmap/handler/rails/template.rb', line 59

def path
  @path
end

#render_instanceObject (readonly)

This is basically the self parameter.



57
58
59
# File 'lib/appmap/handler/rails/template.rb', line 57

def render_instance
  @render_instance
end

Instance Method Details

#static?Boolean

Returns:

  • (Boolean)


68
69
70
# File 'lib/appmap/handler/rails/template.rb', line 68

def static?
  true
end

#to_hObject



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/appmap/handler/rails/template.rb', line 72

def to_h
  super.tap do |h|
    h[:defined_class] = path ? path.parameterize.underscore : 'inline_template'
    h[:method_id] = 'render'
    h[:path] = path
    h[:static] = static?
    h[:parameters] = []
    h[:receiver] = {
      class: AppMap::Event::MethodEvent.best_class_name(render_instance),
      object_id: render_instance.__id__,
      value: AppMap::Event::MethodEvent.display_string(render_instance)
    }
    h.compact
  end
end