Class: Aikido::Zen::Collector::Event

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

Constant Summary collapse

@@registry =
{}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeEvent

Returns a new instance of Event.



22
23
24
# File 'lib/aikido/zen/collector/event.rb', line 22

def initialize
  @type = self.class::TYPE
end

Instance Attribute Details

#typeObject (readonly)

Returns the value of attribute type.



20
21
22
# File 'lib/aikido/zen/collector/event.rb', line 20

def type
  @type
end

Class Method Details

.from_json(data) ⇒ Object



14
15
16
17
18
# File 'lib/aikido/zen/collector/event.rb', line 14

def self.from_json(data)
  type = data[:type]
  subclass = @@registry[type]
  subclass.from_json(data)
end

.register(type) ⇒ Object



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

def self.register(type)
  const_set(:TYPE, type)
  @@registry[type] = self
end

Instance Method Details

#as_jsonObject



26
27
28
29
30
# File 'lib/aikido/zen/collector/event.rb', line 26

def as_json
  {
    type: @type
  }
end

#handle(collector) ⇒ Object

Raises:

  • (NotImplementedError)


32
33
34
# File 'lib/aikido/zen/collector/event.rb', line 32

def handle(collector)
  raise NotImplementedError, "implement in subclasses"
end