Class: ActiveSupport::TagStack

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

Overview

:nodoc:

Constant Summary collapse

EMPTY_TAGS =
{}.freeze
FIBER_KEY =
:event_reporter_tags

Class Method Summary collapse

Class Method Details

.tagsObject



11
12
13
# File 'lib/active_support/event_reporter.rb', line 11

def tags
  Fiber[FIBER_KEY] || EMPTY_TAGS
end

.with_tags(*args, **kwargs) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/active_support/event_reporter.rb', line 15

def with_tags(*args, **kwargs)
  existing_tags = tags
  tags = existing_tags.dup
  tags.merge!(resolve_tags(args, kwargs))
  new_tags = tags.freeze

  begin
    Fiber[FIBER_KEY] = new_tags
    yield
  ensure
    Fiber[FIBER_KEY] = existing_tags
  end
end