Class: Warren::Callback::BroadcastWithWarren
- Inherits:
-
Object
- Object
- Warren::Callback::BroadcastWithWarren
- Defined in:
- lib/warren/callback/broadcast_with_warren.rb
Overview
Warren::Callback::BroadcastWithWarren is a Callback class which is used to handle message broadcast of ActiveRecord::Base objects on commit
Instance Attribute Summary collapse
-
#handler ⇒ Object
readonly
Returns the value of attribute handler.
-
#message_class ⇒ Object
readonly
Returns the value of attribute message_class.
Instance Method Summary collapse
- #after_commit(record) ⇒ Object
-
#initialize(handler:, message_class: Warren::Message::Short) ⇒ BroadcastWithWarren
constructor
Creates the callback object.
Constructor Details
#initialize(handler:, message_class: Warren::Message::Short) ⇒ BroadcastWithWarren
Creates the callback object
20 21 22 23 |
# File 'lib/warren/callback/broadcast_with_warren.rb', line 20 def initialize(handler:, message_class: Warren::Message::Short) @handler = handler @message_class = end |
Instance Attribute Details
#handler ⇒ Object (readonly)
Returns the value of attribute handler.
12 13 14 |
# File 'lib/warren/callback/broadcast_with_warren.rb', line 12 def handler @handler end |
#message_class ⇒ Object (readonly)
Returns the value of attribute message_class.
12 13 14 |
# File 'lib/warren/callback/broadcast_with_warren.rb', line 12 def @message_class end |
Instance Method Details
#after_commit(record) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/warren/callback/broadcast_with_warren.rb', line 25 def after_commit(record) # Message rendering is slow in some cases. This broadcasts an initial # lightweight message which can be picked up and rendered asynchronously # Borrows connection as per #broadcast handler << .new(record) end |