Class: Lyra::Event
- Inherits:
-
RailsEventStore::Event
- Object
- RailsEventStore::Event
- Lyra::Event
- Defined in:
- lib/lyra/event.rb
Overview
Base event class for all Lyra events
Class Method Summary collapse
Instance Method Summary collapse
- #attributes ⇒ Object
- #changes ⇒ Object
-
#model_class ⇒ Object
Accessor methods that handle both symbol and string keys (JSON serializer converts symbols to strings).
- #model_id ⇒ Object
- #operation ⇒ Object
- #request_id ⇒ Object
- #timestamp ⇒ Object
- #user_id ⇒ Object
Class Method Details
.inherited(subclass) ⇒ Object
4 5 6 7 8 |
# File 'lib/lyra/event.rb', line 4 def self.inherited(subclass) super # Auto-register event types Lyra::EventRegistry.register(subclass) end |
Instance Method Details
#attributes ⇒ Object
25 26 27 |
# File 'lib/lyra/event.rb', line 25 def attributes data[:attributes] || data["attributes"] || {} end |
#changes ⇒ Object
29 30 31 |
# File 'lib/lyra/event.rb', line 29 def changes data[:changes] || data["changes"] || {} end |
#model_class ⇒ Object
Accessor methods that handle both symbol and string keys (JSON serializer converts symbols to strings)
12 13 14 |
# File 'lib/lyra/event.rb', line 12 def model_class data[:model_class] || data["model_class"] end |
#model_id ⇒ Object
16 17 18 |
# File 'lib/lyra/event.rb', line 16 def model_id data[:model_id] || data["model_id"] end |
#operation ⇒ Object
20 21 22 23 |
# File 'lib/lyra/event.rb', line 20 def operation op = data[:operation] || data["operation"] op.is_a?(String) ? op.to_sym : op end |
#request_id ⇒ Object
43 44 45 46 47 |
# File 'lib/lyra/event.rb', line 43 def request_id # request_id is stored in data[:metadata] (nested), not top-level metadata nested = data[:metadata] || data["metadata"] || {} nested[:request_id] || nested["request_id"] || [:request_id] end |
#timestamp ⇒ Object
33 34 35 |
# File 'lib/lyra/event.rb', line 33 def data[:timestamp] || data["timestamp"] || [:timestamp] end |
#user_id ⇒ Object
37 38 39 40 41 |
# File 'lib/lyra/event.rb', line 37 def user_id # user_id is stored in data[:metadata] (nested), not top-level metadata nested = data[:metadata] || data["metadata"] || {} nested[:user_id] || nested["user_id"] || [:user_id] end |