Class: Bidi2pdf::Notifications::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/bidi2pdf/notifications/event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, start, ending, transaction_id, payload) ⇒ Event

Returns a new instance of Event.



10
11
12
13
14
15
16
# File 'lib/bidi2pdf/notifications/event.rb', line 10

def initialize(name, start, ending, transaction_id, payload)
  @name = name
  @payload = payload
  @time = start ? start.to_f * 1_000.0 : start
  @transaction_id = transaction_id
  @end = ending ? ending.to_f * 1_000.0 : ending
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/bidi2pdf/notifications/event.rb', line 7

def name
  @name
end

#payloadObject

Returns the value of attribute payload.



8
9
10
# File 'lib/bidi2pdf/notifications/event.rb', line 8

def payload
  @payload
end

#transaction_idObject (readonly)

Returns the value of attribute transaction_id.



7
8
9
# File 'lib/bidi2pdf/notifications/event.rb', line 7

def transaction_id
  @transaction_id
end

Instance Method Details

#durationObject



35
# File 'lib/bidi2pdf/notifications/event.rb', line 35

def duration = @end - @time

#endObject



41
42
43
# File 'lib/bidi2pdf/notifications/event.rb', line 41

def end
  @end / 1000.0 if @end
end

#finish!Object



33
# File 'lib/bidi2pdf/notifications/event.rb', line 33

def finish! = @end = now

#recordObject

:nodoc:



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/bidi2pdf/notifications/event.rb', line 18

def record # :nodoc:
  start!
  begin
    yield payload if block_given?
  rescue Exception => e
    payload[:exception] = [e.class.name, e.message]
    payload[:exception_object] = e
    raise e
  ensure
    finish!
  end
end

#start!Object



31
# File 'lib/bidi2pdf/notifications/event.rb', line 31

def start! = @time = now

#timeObject



37
38
39
# File 'lib/bidi2pdf/notifications/event.rb', line 37

def time
  @time / 1000.0 if @time
end