Class: Console::Event::Generic

Inherits:
Object
  • Object
show all
Defined in:
lib/console/event/generic.rb

Overview

A generic event which can be used to represent structured data.

Direct Known Subclasses

Failure, Spawn

Instance Method Summary collapse

Instance Method Details

#as_jsonObject

Convert the event to a hash suitable for JSON serialization.



13
14
15
# File 'lib/console/event/generic.rb', line 13

def as_json(...)
	to_hash
end

#emit(*arguments, **options) ⇒ Object

Log the event using the given output interface.



35
36
37
# File 'lib/console/event/generic.rb', line 35

def emit(*arguments, **options)
	Console.call(*arguments, event: self, **options)
end

#to_jsonObject

Serialize the event to JSON.



20
21
22
# File 'lib/console/event/generic.rb', line 20

def to_json(...)
	JSON.generate(as_json, ...)
end

#to_sObject

Convert the event to a string (JSON).



27
28
29
# File 'lib/console/event/generic.rb', line 27

def to_s
	to_json
end