class ActionPubsub::Event

Public Class Methods

new(topic:, record:nil, context: nil, **options) click to toggle source

attributes have to be set for purposes of marshaling

# File lib/action_pubsub/event.rb, line 19
def initialize(topic:, record:nil, context: nil, **options)
  self[:topic] = topic
  self[:action] = topic.split("/").pop.to_sym
  self[:meta] = options[:meta] || {}
  self[:name] = topic
  self[:record] = record
  self[:id] = ::SecureRandom.hex
  self[:subject] = options[:subject] || record.try(:class).try(:name)
  self[:context] = context if context
  self[:occured_at] ||= ::Time.now.to_i
end