module Warren::Callback::ClassMethods

Provides the broadcast_with_warren and broadcasts_associated_with_warren to ActiveRecord::Base classes to configure broadcast

Attributes

associated_to_broadcast[R]
warren[R]

Public Instance Methods

broadcast_with_warren(handler: Warren.handler) click to toggle source

Records of this type are broadcast via RabbitMQ when a transaction is closed.

@return [void]

# File lib/warren/callback.rb, line 23
def broadcast_with_warren(handler: Warren.handler)
  after_commit BroadcastWithWarren.new(handler: handler)
end
broadcasts_associated_with_warren(*associated, handler: Warren.handler) click to toggle source

When records of this type are saved, broadcast the associated records once the transaction is closed. (Requires that associated record is broadcast_with_warren)

@param [Symbol,Array<Symbol>] associated One or more symbols indicating the associations to broadcast.

@return [void]

# File lib/warren/callback.rb, line 35
def broadcasts_associated_with_warren(*associated, handler: Warren.handler)
  after_save BroadcastAssociatedWithWarren.new(associated, handler: handler)
end