Module: SolidObjects::ActorHelper

Included in:
Engine
Defined in:
app/helpers/solid_objects/actor_helper.rb,
sig/generated/helpers/solid_objects/actor_helper.rbs

Instance Method Summary collapse

Instance Method Details

#solid_object(reference, authorization_context: self) {|arg0| ... } ⇒ Object

RBS:

  • (Reference, ?authorization_context: untyped) { (ActorView) -> untyped } -> untyped

Parameters:

  • (Reference)
  • authorization_context: (Object) (defaults to: self)

Yields:

Yield Parameters:

Yield Returns:

  • (Object)

Returns:

  • (Object)


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
33
34
35
36
37
38
39
# 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_data = {
    token: StreamToken.generate(
      reference,
      observables: actor.scalar_observable_names
    )
  }
  if actor.component_tokens.any?
    subscription_data[:components] = JSON.generate(actor.component_tokens)
  end
  subscription = tag.turbo_cable_stream_source(
    channel: "SolidObjects::ActorChannel",
    data: subscription_data
  )
  refresh_client = if actor.morph_components?
    javascript_include_tag(
      "solid_objects/component_refresh",
      type: "module",
      data: { turbo_track: "reload" }
    )
  end

  (
    :div,
    safe_join([ refresh_client, subscription, content ].compact),
    id: DomIdentity.scope(reference)
  )
end