6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'app/helpers/solid_objects/actor_helper.rb', line 6
def solid_object(reference, authorization_context: self, &block)
actor = ActorView.new(
reference:,
view_context: self,
authorization_context:
)
content = capture(actor, &block)
subscription_attributes = {
channel: "SolidObjects::ActorChannel",
token: StreamToken.generate(
reference,
observables: actor.scalar_observable_names
)
}
if actor.component_tokens.any?
subscription_attributes[:data] = {
components: JSON.generate(actor.component_tokens)
}
end
subscription = tag.turbo_cable_stream_source(**subscription_attributes)
content_tag(
:div,
safe_join([ subscription, content ]),
id: DomIdentity.scope(reference)
)
end
|