module Aws::Broker::Publishing

Public Instance Methods

publish_event(*events) click to toggle source

only :create, :update, :destroy

# File lib/aws/broker/publishing.rb, line 6
def publish_event(*events)
  events.each do |event|
    event = event.to_sym
    unless [:create, :update, :destroy].include?(event)
      raise "Invalid publish event #{event}"
    end
    method_name = :"publish_event_#{event}"
    define_method method_name do
      Broker.publish(
        self.class.publish_topic,
        event:      event,
        id:         id,
        attributes: attributes
      )
    end
    after_commit method_name, on: event
  end
end
publish_topic() click to toggle source
# File lib/aws/broker/publishing.rb, line 25
def publish_topic
  if defined?(@@publish_topic)
    @@publish_topic
  else
    to_s.underscore.tr('/', '_')
  end
end
publish_topic=(topic) click to toggle source

optional override of default topic

# File lib/aws/broker/publishing.rb, line 34
def publish_topic=(topic)
  @@publish_topic = topic
end