Class: Airbrake::Context Private
- Inherits:
-
Object
- Object
- Airbrake::Context
- Defined in:
- lib/airbrake-ruby/context.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Represents a thread-safe Airbrake context object, which carries arbitrary information added via merge_context calls.
Class Method Summary collapse
-
.current ⇒ self
private
Returns current, thread-local, context.
Instance Method Summary collapse
-
#clear ⇒ Hash
private
Clears (resets) the current context.
-
#empty? ⇒ Boolean
private
Checks whether the context has any data.
-
#initialize ⇒ Context
constructor
private
A new instance of Context.
-
#merge!(other) ⇒ void
private
Merges the given context with the current one.
-
#to_h ⇒ Hash
private
Duplicated Hash context.
Constructor Details
#initialize ⇒ Context
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Context.
17 18 19 20 |
# File 'lib/airbrake-ruby/context.rb', line 17 def initialize @mutex = Mutex.new @context = {} end |
Class Method Details
.current ⇒ self
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns current, thread-local, context.
13 14 15 |
# File 'lib/airbrake-ruby/context.rb', line 13 def self.current Thread.current[:airbrake_context] ||= new end |
Instance Method Details
#clear ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns clears (resets) the current context.
40 41 42 43 44 |
# File 'lib/airbrake-ruby/context.rb', line 40 def clear @mutex.synchronize do @context.clear end end |
#empty? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns checks whether the context has any data.
47 48 49 |
# File 'lib/airbrake-ruby/context.rb', line 47 def empty? @context.empty? end |
#merge!(other) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Merges the given context with the current one.
26 27 28 29 30 |
# File 'lib/airbrake-ruby/context.rb', line 26 def merge!(other) @mutex.synchronize do @context.merge!(other) end end |
#to_h ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns duplicated Hash context.
33 34 35 36 37 |
# File 'lib/airbrake-ruby/context.rb', line 33 def to_h @mutex.synchronize do @context.dup end end |