Class: Aikido::Zen::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/aikido/zen/event.rb

Overview

Base class for all events. You should be using one of the subclasses defined in the Events module.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, system_info: Aikido::Zen.system_info, time: Time.now.utc) ⇒ Event

Returns a new instance of Event.



11
12
13
14
15
# File 'lib/aikido/zen/event.rb', line 11

def initialize(type:, system_info: Aikido::Zen.system_info, time: Time.now.utc)
  @type = type
  @time = time
  @system_info = system_info
end

Instance Attribute Details

#system_infoObject (readonly)

Returns the value of attribute system_info.



9
10
11
# File 'lib/aikido/zen/event.rb', line 9

def system_info
  @system_info
end

#timeObject (readonly)

Returns the value of attribute time.



8
9
10
# File 'lib/aikido/zen/event.rb', line 8

def time
  @time
end

#typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

Instance Method Details

#as_jsonObject



17
18
19
20
21
22
23
# File 'lib/aikido/zen/event.rb', line 17

def as_json
  {
    type: type,
    time: time.to_i * 1000,
    agent: system_info.as_json
  }
end