Module: Plutonium::Kanban::Broadcaster
Overview
Builds ActionCable stream names and broadcasts Turbo Stream updates for opt-in realtime kanban boards.
Tenant isolation
The stream name is a three-segment string:
"kanban:<tenant>:<resource>"
where
Two viewers are on the SAME stream only when they share identical resource_class AND scoped_entity — different tenants can never share a stream because their GID params are distinct by definition.
Instance Method Summary collapse
-
#broadcast(resource_class:, scoped_entity:, content:) ⇒ Object
Broadcasts the Turbo Stream HTML to all ActionCable subscribers watching this board's stream.
-
#stream_name(resource_class:, scoped_entity:) ⇒ Array<String>
Returns the streamables array that identifies this board's ActionCable stream.
Instance Method Details
#broadcast(resource_class:, scoped_entity:, content:) ⇒ Object
Broadcasts the Turbo Stream HTML to all ActionCable subscribers watching this board's stream.
46 47 48 49 50 51 |
# File 'lib/plutonium/kanban/broadcaster.rb', line 46 def broadcast(resource_class:, scoped_entity:, content:) Turbo::StreamsChannel.broadcast_stream_to( *stream_name(resource_class:, scoped_entity:), content: content ) end |
#stream_name(resource_class:, scoped_entity:) ⇒ Array<String>
Returns the streamables array that identifies this board's ActionCable stream.
Pass the returned array directly to turbo-rails helpers:
turbo_stream_from(*Broadcaster.stream_name(resource_class: Task, scoped_entity: org))
Turbo::StreamsChannel.broadcast_stream_to(*stream_name, content:)
34 35 36 37 |
# File 'lib/plutonium/kanban/broadcaster.rb', line 34 def stream_name(resource_class:, scoped_entity:) entity_segment = scoped_entity&.to_gid_param || "global" ["kanban", entity_segment, resource_class.name] end |