Class: AppMap::Handler::Rails::RenderHandler

Inherits:
FunctionHandler show all
Defined in:
lib/appmap/handler/rails/render_handler.rb

Constant Summary

Constants inherited from AppMap::Hook::Method

AppMap::Hook::Method::HOOK_DISABLE_KEY

Constants included from AppMap::Hook::RecordAround

AppMap::Hook::RecordAround::APPMAP_OUTPUT_DIR

Instance Attribute Summary

Attributes inherited from AppMap::Hook::Method

#arity, #hook_class, #hook_method, #hook_package, #parameters, #record_around

Instance Method Summary collapse

Methods inherited from AppMap::Hook::Method

#activate, #call, #initialize

Methods included from AppMap::Hook::RecordAround

#record_around?, #record_around_after, #record_around_before

Constructor Details

This class inherits a constructor from AppMap::Hook::Method

Instance Method Details

#handle_call(receiver, args) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/appmap/handler/rails/render_handler.rb', line 7

def handle_call(receiver, args)
  options, _ = args
  # TODO: :file, :xml
  # https://guides.rubyonrails.org/v5.1/layouts_and_rendering.html
  if options[:json]
    Thread.current[TEMPLATE_RENDER_FORMAT] = :json
  end

  super
end

#handle_return(call_event_id, elapsed, return_value, exception) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/appmap/handler/rails/render_handler.rb', line 18

def handle_return(call_event_id, elapsed, return_value, exception)
  if Thread.current[TEMPLATE_RENDER_FORMAT] == :json
    Thread.current[TEMPLATE_RENDER_VALUE] = JSON.parse(return_value) rescue nil
  end
  Thread.current[TEMPLATE_RENDER_FORMAT] = nil

  super
end