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_hash ⇒ Object
Convert the event to a hash suitable for JSON serialization.
-
#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.
20 21 22 |
# File 'lib/console/event/generic.rb', line 20 def as_json(...) to_hash end |
#emit(*arguments, **options) ⇒ Object
Log the event using the given output interface.
42 43 44 |
# File 'lib/console/event/generic.rb', line 42 def emit(*arguments, **) Console.call(*arguments, event: self, **) end |
#to_hash ⇒ Object
Convert the event to a hash suitable for JSON serialization.
13 14 15 |
# File 'lib/console/event/generic.rb', line 13 def to_hash {} end |
#to_json ⇒ Object
Serialize the event to JSON.
27 28 29 |
# File 'lib/console/event/generic.rb', line 27 def to_json(...) JSON.generate(as_json, ...) end |
#to_s ⇒ Object
Convert the event to a string (JSON).
34 35 36 |
# File 'lib/console/event/generic.rb', line 34 def to_s to_json end |