Class: Events::MessageCreated

Inherits:
Object
  • Object
show all
Defined in:
lib/events/message_created.rb

Overview

Emitted after a Message record is committed to the database. Subscribers react to persisted messages — not to raw domain events.

Carries the Message record directly so subscribers don’t need to look it up again.

Constant Summary collapse

TYPE =
"message.created"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message) ⇒ MessageCreated

Returns a new instance of MessageCreated.

Parameters:

  • message (Message)

    the persisted message record



15
16
17
# File 'lib/events/message_created.rb', line 15

def initialize(message)
  @message = message
end

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message.



12
13
14
# File 'lib/events/message_created.rb', line 12

def message
  @message
end

Instance Method Details

#event_nameObject



19
20
21
# File 'lib/events/message_created.rb', line 19

def event_name
  "#{Bus::NAMESPACE}.#{TYPE}"
end

#to_hObject



23
24
25
# File 'lib/events/message_created.rb', line 23

def to_h
  {type: TYPE, message:}
end