Class: EventLoggerRails::Message
- Inherits:
-
Object
- Object
- EventLoggerRails::Message
- Defined in:
- lib/event_logger_rails/message.rb
Overview
Models a message sent to the logger containing event and optional data
Instance Method Summary collapse
-
#initialize(event:, data: {}) ⇒ Message
constructor
Initializes the message with the given event and data.
-
#to_hash ⇒ Hash
Converts the message to a hash containing the event and data details.
Constructor Details
#initialize(event:, data: {}) ⇒ Message
Initializes the message with the given event and data.
10 11 12 13 |
# File 'lib/event_logger_rails/message.rb', line 10 def initialize(event:, data: {}) @event = event @data = data end |
Instance Method Details
#to_hash ⇒ Hash
Converts the message to a hash containing the event and data details.
18 19 20 |
# File 'lib/event_logger_rails/message.rb', line 18 def to_hash event.merge(data) end |