Class: ActiveSupport::EventContext

Inherits:
Object
  • Object
show all
Defined in:
lib/active_support/event_reporter.rb

Overview

:nodoc:

Constant Summary collapse

EMPTY_CONTEXT =
{}.freeze
FIBER_KEY =
:event_reporter_context

Class Method Summary collapse

Class Method Details

.clearObject



65
66
67
# File 'lib/active_support/event_reporter.rb', line 65

def clear
  Fiber[FIBER_KEY] = EMPTY_CONTEXT
end

.contextObject



54
55
56
# File 'lib/active_support/event_reporter.rb', line 54

def context
  Fiber[FIBER_KEY] || EMPTY_CONTEXT
end

.set_context(context_hash) ⇒ Object



58
59
60
61
62
63
# File 'lib/active_support/event_reporter.rb', line 58

def set_context(context_hash)
  new_context = self.context.dup
  context_hash.each { |key, value| new_context[key.to_sym] = value }

  Fiber[FIBER_KEY] = new_context.freeze
end