Class: Technologic::Event

Inherits:
Object
  • Object
show all
Includes:
ShortCircuIt
Defined in:
lib/technologic/event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, started, finished, payload) ⇒ Event

Returns a new instance of Event.



9
10
11
12
13
# File 'lib/technologic/event.rb', line 9

def initialize(name, started, finished, payload)
  @name = name
  @duration = finished - started
  @payload = payload
end

Instance Attribute Details

#durationObject (readonly)

Returns the value of attribute duration.



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

def duration
  @duration
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

Instance Method Details

#dataObject



15
16
17
18
19
20
21
# File 'lib/technologic/event.rb', line 15

def data
  {}.tap do |hash|
    hash.merge!(@payload)
    hash[:event] = name
    hash[:duration] = duration if duration.round > 0
  end
end