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

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, encode_display_string, object_properties

Constructor Details

#initialize(render_instance) ⇒ TemplateCall

Returns a new instance of TemplateCall.



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

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.



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

def path
  @path
end

#readyObject Also known as: ready?

Indicates when the event is fully constructed.



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

def ready
  @ready
end

#render_instanceObject (readonly)

This is basically the self parameter.



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

def render_instance
  @render_instance
end

Instance Method Details

#static?Boolean

Returns:

  • (Boolean)


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

def static?
  true
end

#to_hObject



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

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