Class: ActionPubsub::Event
- Inherits:
-
Object
- Object
- ActionPubsub::Event
- Includes:
- ActiveAttr::Model, ActiveModel::AttributeMethods
- Defined in:
- lib/action_pubsub/event.rb
Instance Method Summary collapse
-
#initialize(topic:, record: nil, context: nil, **options) ⇒ Event
constructor
attributes have to be set for purposes of marshaling.
Constructor Details
#initialize(topic:, record: nil, context: nil, **options) ⇒ Event
attributes have to be set for purposes of marshaling
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/action_pubsub/event.rb', line 19 def initialize(topic:, record:nil, context: nil, **) self[:topic] = topic self[:action] = topic.split("/").pop.to_sym self[:meta] = [:meta] || {} self[:name] = topic self[:record] = record self[:id] = ::SecureRandom.hex self[:subject] = [:subject] || record.try(:class).try(:name) self[:context] = context if context self[:occured_at] ||= ::Time.now.to_i end |