Class: EventLoggerRails::Message

Inherits:
Object
  • Object
show all
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

Constructor Details

#initialize(event:, data: {}) ⇒ Message

Initializes the message with the given event and data.

Parameters:



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_hashHash

Converts the message to a hash containing the event and data details.

Returns:

  • (Hash)

    The hash representation of the message.



18
19
20
# File 'lib/event_logger_rails/message.rb', line 18

def to_hash
  event.merge(data)
end