123456789_123456789_123456789_123456789_123456789_

Class: ActiveSupport::TagStack

Do not use. This class is for internal use only.
Relationships & Source Files
Inherits: Object
Defined in: activesupport/lib/active_support/event_reporter.rb

Constant Summary

Class Method Summary

Class Method Details

.resolve_tags(args, kwargs) (private)

[ GitHub ]

  
# File 'activesupport/lib/active_support/event_reporter.rb', line 28

def resolve_tags(args, kwargs)
  tags = args.each_with_object({}) do |arg, tags|
    case arg
    when String
      tags[arg.to_sym] = true
    when Symbol
      tags[arg] = true
    when Hash
      arg.each { |key, value| tags[key.to_sym] = value }
    else
      tags[arg.class.name.to_sym] = arg
    end
  end
  kwargs.each { |key, value| tags[key.to_sym] = value }
  tags
end

.tags

[ GitHub ]

  
# File 'activesupport/lib/active_support/event_reporter.rb', line 9

def tags
  Fiber[FIBER_KEY] || EMPTY_TAGS
end

.with_tags(*args, **kwargs)

[ GitHub ]

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

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