Class: Celluloid::Incident
- Inherits:
-
Object
- Object
- Celluloid::Incident
- Defined in:
- lib/celluloid/logging/incident.rb
Overview
Wraps all events and context for a single incident.
Instance Attribute Summary collapse
-
#events ⇒ Object
Returns the value of attribute events.
-
#pid ⇒ Object
Returns the value of attribute pid.
-
#triggering_event ⇒ Object
Returns the value of attribute triggering_event.
Instance Method Summary collapse
-
#initialize(events, triggering_event = nil) ⇒ Incident
constructor
A new instance of Incident.
-
#merge(*other_incidents) ⇒ Object
Merge two incidents together.
Constructor Details
#initialize(events, triggering_event = nil) ⇒ Incident
Returns a new instance of Incident.
7 8 9 10 11 |
# File 'lib/celluloid/logging/incident.rb', line 7 def initialize(events, triggering_event=nil) @events = events @triggering_event = triggering_event @pid = $PROCESS_ID end |
Instance Attribute Details
#events ⇒ Object
Returns the value of attribute events.
5 6 7 |
# File 'lib/celluloid/logging/incident.rb', line 5 def events @events end |
#pid ⇒ Object
Returns the value of attribute pid.
4 5 6 |
# File 'lib/celluloid/logging/incident.rb', line 4 def pid @pid end |
#triggering_event ⇒ Object
Returns the value of attribute triggering_event.
5 6 7 |
# File 'lib/celluloid/logging/incident.rb', line 5 def triggering_event @triggering_event end |
Instance Method Details
#merge(*other_incidents) ⇒ Object
Merge two incidents together. This may be useful if two incidents occur at the same time.
14 15 16 17 18 19 |
# File 'lib/celluloid/logging/incident.rb', line 14 def merge(*other_incidents) merged_events = other_incidents.flatten.inject(events) do |events, incident| events += incident.events end Incident.new(merged_events.sort, triggering_event) end |