Class: Console::Event::Generic
- Inherits:
-
Object
- Object
- Console::Event::Generic
- Defined in:
- lib/console/event/generic.rb
Overview
A generic event which can be used to represent structured data.
Instance Method Summary collapse
-
#as_json ⇒ Object
Convert the event to a hash suitable for JSON serialization.
-
#emit(*arguments, **options) ⇒ Object
Log the event using the given output interface.
-
#to_json ⇒ Object
Serialize the event to JSON.
-
#to_s ⇒ Object
Convert the event to a string (JSON).
Instance Method Details
#as_json ⇒ Object
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, **) Console.call(*arguments, event: self, **) end |
#to_json ⇒ Object
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_s ⇒ Object
Convert the event to a string (JSON).
27 28 29 |
# File 'lib/console/event/generic.rb', line 27 def to_s to_json end |