Class: Bidi2pdf::Notifications::Event
- Inherits:
-
Object
- Object
- Bidi2pdf::Notifications::Event
- Defined in:
- lib/bidi2pdf/notifications/event.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#payload ⇒ Object
Returns the value of attribute payload.
-
#transaction_id ⇒ Object
readonly
Returns the value of attribute transaction_id.
Instance Method Summary collapse
- #duration ⇒ Object
- #end ⇒ Object
- #finish! ⇒ Object
-
#initialize(name, start, ending, transaction_id, payload) ⇒ Event
constructor
A new instance of Event.
-
#record ⇒ Object
:nodoc:.
- #start! ⇒ Object
- #time ⇒ Object
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
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/bidi2pdf/notifications/event.rb', line 7 def name @name end |
#payload ⇒ Object
Returns the value of attribute payload.
8 9 10 |
# File 'lib/bidi2pdf/notifications/event.rb', line 8 def payload @payload end |
#transaction_id ⇒ Object (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
#duration ⇒ Object
35 |
# File 'lib/bidi2pdf/notifications/event.rb', line 35 def duration = @end - @time |
#end ⇒ Object
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 |
#record ⇒ Object
: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.] 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 |
#time ⇒ Object
37 38 39 |
# File 'lib/bidi2pdf/notifications/event.rb', line 37 def time @time / 1000.0 if @time end |