Class: AppMap::Handler::Rails::Template::ResolverHandler
- Inherits:
-
Object
- Object
- AppMap::Handler::Rails::Template::ResolverHandler
- Defined in:
- lib/appmap/handler/rails/template.rb
Overview
Hooks the ActionView::Resolver methods find_all, find_all_anywhere. The resolver is used during template rendering to lookup the template file path from parameters such as the template name, prefix, and partial (boolean).
Class Method Summary collapse
-
.handle_call(defined_class, hook_method, receiver, args) ⇒ Object
Handled as a normal function call.
-
.handle_return(call_event_id, elapsed, return_value, exception) ⇒ Object
When the resolver returns, look to see if there is template rendering underway.
Class Method Details
.handle_call(defined_class, hook_method, receiver, args) ⇒ Object
Handled as a normal function call.
97 98 99 100 101 102 |
# File 'lib/appmap/handler/rails/template.rb', line 97 def handle_call(defined_class, hook_method, receiver, args) name, prefix, partial = args warn "Resolver: #{{ name: name, prefix: prefix, partial: partial }}" if LOG AppMap::Handler::Function.handle_call(defined_class, hook_method, receiver, args) end |
.handle_return(call_event_id, elapsed, return_value, exception) ⇒ Object
When the resolver returns, look to see if there is template rendering underway. If so, populate the template path. In all cases, add a TemplateMethod so that the template will be recorded in the classMap.
107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/appmap/handler/rails/template.rb', line 107 def handle_return(call_event_id, elapsed, return_value, exception) warn "Resolver return: #{return_value.inspect}" if LOG renderer = Array(Thread.current[TEMPLATE_RENDERER]).last path = Array(return_value).first&.inspect if path AppMap.tracing.record_method(TemplateMethod.new(path)) renderer.path ||= path if renderer end AppMap::Handler::Function.handle_return(call_event_id, elapsed, return_value, exception) end |