Module: Superview::Helpers::Turbo

Extended by:
ActiveSupport::Concern
Defined in:
lib/superview/helpers/turbo.rb,
lib/superview/helpers/turbo/meta_tags.rb

Defined Under Namespace

Classes: MetaTags

Instance Method Summary collapse

Instance Method Details

#stream_from(*streamables) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/superview/helpers/turbo.rb', line 16

def stream_from(*streamables)
  streamables.each do |streamable|
    case streamable
      in association: ActiveRecord::Relation
        association.each { turbo_stream_from streamable }
      else
        turbo_stream_from streamable
    end
  end
end

#turbo_stream_from(*streamables, **attributes) ⇒ Object



10
11
12
13
14
# File 'lib/superview/helpers/turbo.rb', line 10

def turbo_stream_from(*streamables, **attributes)
  attributes[:channel] = attributes[:channel]&.to_s || "Turbo::StreamsChannel"
  attributes[:"signed-stream-name"] = ::Turbo::StreamsChannel.signed_stream_name(streamables)
  turbo_cable_stream_source **attributes, class: "hidden", style: "display: none;"
end