Class: AppMap::Handler::Rails::Context
- Defined in:
- lib/appmap/handler/rails/context.rb
Overview
Context of a rails request tracking. Mostly a utility class to clean up and deduplicate request handler code.
Constant Summary collapse
- REQUEST_CONTEXT =
context is set on the rack environment to make sure a single request is only recorded once even if ActionDispatch::Executor is entered more than once (as can happen with engines)
'appmap.handler.request.context'
Class Method Summary collapse
Instance Method Summary collapse
- #find_template_render_value ⇒ Object
-
#initialize(environment = nil) ⇒ Context
constructor
A new instance of Context.
Constructor Details
#initialize(environment = nil) ⇒ Context
Returns a new instance of Context.
11 12 13 14 |
# File 'lib/appmap/handler/rails/context.rb', line 11 def initialize(environment = nil) environment[REQUEST_CONTEXT] = self if environment @thread = Thread.current end |
Class Method Details
.create(environment) ⇒ Object
20 21 22 23 24 |
# File 'lib/appmap/handler/rails/context.rb', line 20 def self.create(environment) return if from environment new environment end |
.from(environment) ⇒ Object
16 17 18 |
# File 'lib/appmap/handler/rails/context.rb', line 16 def self.from(environment) environment[REQUEST_CONTEXT] end |
.remove(env) ⇒ Object
26 27 28 |
# File 'lib/appmap/handler/rails/context.rb', line 26 def self.remove(env) env[REQUEST_CONTEXT] = nil end |
Instance Method Details
#find_template_render_value ⇒ Object
30 31 32 33 34 |
# File 'lib/appmap/handler/rails/context.rb', line 30 def find_template_render_value @thread[TEMPLATE_RENDER_VALUE].tap do @thread[TEMPLATE_RENDER_VALUE] = nil end end |