Module: Warren::Callback::ClassMethods
- Defined in:
- lib/warren/callback.rb
Overview
Provides the broadcast_with_warren and broadcasts_associated_with_warren to ActiveRecord::Base classes to configure broadcast
Instance Attribute Summary collapse
-
#associated_to_broadcast ⇒ Object
readonly
Returns the value of attribute associated_to_broadcast.
-
#warren ⇒ Object
readonly
Returns the value of attribute warren.
Instance Method Summary collapse
-
#broadcast_with_warren(handler: Warren.handler) ⇒ void
Records of this type are broadcast via RabbitMQ when a transaction is closed.
-
#broadcasts_associated_with_warren(*associated, handler: Warren.handler) ⇒ void
When records of this type are saved, broadcast the associated records once the transaction is closed.
Instance Attribute Details
#associated_to_broadcast ⇒ Object (readonly)
Returns the value of attribute associated_to_broadcast.
16 17 18 |
# File 'lib/warren/callback.rb', line 16 def associated_to_broadcast @associated_to_broadcast end |
#warren ⇒ Object (readonly)
Returns the value of attribute warren.
16 17 18 |
# File 'lib/warren/callback.rb', line 16 def warren @warren end |
Instance Method Details
#broadcast_with_warren(handler: Warren.handler) ⇒ void
This method returns an undefined value.
Records of this type are broadcast via RabbitMQ when a transaction is closed.
23 24 25 |
# 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) ⇒ void
This method returns an undefined value.
When records of this type are saved, broadcast the associated records once the transaction is closed. (Requires that associated record is broadcast_with_warren)
35 36 37 |
# File 'lib/warren/callback.rb', line 35 def broadcasts_associated_with_warren(*associated, handler: Warren.handler) after_save BroadcastAssociatedWithWarren.new(associated, handler: handler) end |