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::MAX_ARRAY_ENUMERATION, Event::MethodEvent::MAX_HASH_ENUMERATION, Event::MethodEvent::MAX_STRING_LENGTH

Constants included from ValueInspector

ValueInspector::MAX_ARRAY_ELEMENTS, ValueInspector::MAX_DEPTH

Instance Attribute Summary collapse

Attributes inherited from Event::MethodEventStruct

#event, #id, #thread_id

Instance Method Summary collapse

Methods inherited from Event::MethodEvent

add_schema, add_size, build_from_invocation, custom_display_string, default_display_string, display_string, encode_display_string

Methods included from ValueInspector

#best_class_name, #detect_schema, #detect_size

Constructor Details

#initialize(render_instance) ⇒ TemplateCall

Returns a new instance of TemplateCall.



80
81
82
83
84
85
86
# File 'lib/appmap/handler/rails/template.rb', line 80

def initialize(render_instance)
  super :call

  AppMap::Event::MethodEvent.build_from_invocation(:call, event: self)
  @ready = false
  @render_instance = render_instance
end

Instance Attribute Details

#pathObject

Path to the view template.



74
75
76
# File 'lib/appmap/handler/rails/template.rb', line 74

def path
  @path
end

#readyObject Also known as: ready?

Indicates when the event is fully constructed.



76
77
78
# File 'lib/appmap/handler/rails/template.rb', line 76

def ready
  @ready
end

#render_instanceObject (readonly)

This is basically the self parameter.



72
73
74
# File 'lib/appmap/handler/rails/template.rb', line 72

def render_instance
  @render_instance
end

Instance Method Details

#static?Boolean

Returns:

  • (Boolean)


88
89
90
# File 'lib/appmap/handler/rails/template.rb', line 88

def static?
  true
end

#to_hObject



92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/appmap/handler/rails/template.rb', line 92

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)
    }
  end.compact
end