Class: Celluloid::Incident

Inherits:
Object
  • Object
show all
Defined in:
lib/celluloid/logging/incident.rb

Overview

Wraps all events and context for a single incident.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#eventsObject

Returns the value of attribute events.



5
6
7
# File 'lib/celluloid/logging/incident.rb', line 5

def events
  @events
end

#pidObject

Returns the value of attribute pid.



4
5
6
# File 'lib/celluloid/logging/incident.rb', line 4

def pid
  @pid
end

#triggering_eventObject

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