module Pheromone::Publishable::ClassMethods

class methods for the model including Publishable

Public Instance Methods

publish(message_options) click to toggle source
# File lib/pheromone/publishable.rb, line 39
def publish(message_options)
  errors = Pheromone::Validators::OptionsValidator.new(
    message_options
  ).validate
  raise Pheromone::Exceptions::InvalidPublishOptions.new(errors) unless errors.empty?
  __send__(
    :after_commit,
    proc { dispatch_messages(message_options: message_options, current_event: :create) },
    on: :create
  )
  __send__(
    :after_commit,
    proc { dispatch_messages(message_options: message_options, current_event: :update) },
    on: :update
  )
end