Module: Pgbus::Streams::BroadcastableOverride::ClassMethods
- Defined in:
- lib/pgbus/streams/broadcastable_override.rb
Instance Method Summary collapse
- #broadcasts_refreshes_to(stream, durable: nil) ⇒ Object
- #broadcasts_to(stream, durable: nil, inserts_by: :append, target: broadcast_target_default, **rendering) ⇒ Object
- #pgbus_durable_streams ⇒ Object
Instance Method Details
#broadcasts_refreshes_to(stream, durable: nil) ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/pgbus/streams/broadcastable_override.rb', line 88 def broadcasts_refreshes_to(stream, durable: nil) if durable.nil? after_commit -> { broadcast_refresh_later_to(stream.try(:call, self) || send(stream)) } else @pgbus_durable_streams ||= {} @pgbus_durable_streams[stream] = durable after_commit lambda { broadcast_refresh_to(stream.try(:call, self) || send(stream), durable: durable) } end end |
#broadcasts_to(stream, durable: nil, inserts_by: :append, target: broadcast_target_default, **rendering) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/pgbus/streams/broadcastable_override.rb', line 54 def broadcasts_to(stream, durable: nil, inserts_by: :append, target: broadcast_target_default, **rendering) if durable.nil? after_create_commit lambda { broadcast_action_later_to( stream.try(:call, self) || send(stream), action: inserts_by, target: target.try(:call, self) || target, **rendering ) } after_update_commit -> { broadcast_replace_later_to(stream.try(:call, self) || send(stream), **rendering) } after_destroy_commit -> { broadcast_remove_to(stream.try(:call, self) || send(stream)) } else @pgbus_durable_streams ||= {} @pgbus_durable_streams[stream] = durable after_create_commit lambda { broadcast_action_to( stream.try(:call, self) || send(stream), action: inserts_by, target: target.try(:call, self) || target, durable: durable, **rendering ) } after_update_commit lambda { broadcast_replace_to(stream.try(:call, self) || send(stream), durable: durable, **rendering) } after_destroy_commit lambda { broadcast_remove_to(stream.try(:call, self) || send(stream), durable: durable) } end end |
#pgbus_durable_streams ⇒ Object
101 102 103 |
# File 'lib/pgbus/streams/broadcastable_override.rb', line 101 def pgbus_durable_streams @pgbus_durable_streams || {} end |