Module: RailsMail::TurboHelper

Included in:
BaseController
Defined in:
app/helpers/rails_mail/turbo_helper.rb

Defined Under Namespace

Classes: TurboStreamBuilder

Instance Method Summary collapse

Instance Method Details

#rails_mail_turbo_frame_tag(name, src: nil, &block) ⇒ Object



3
4
5
6
7
8
9
# File 'app/helpers/rails_mail/turbo_helper.rb', line 3

def rails_mail_turbo_frame_tag(name, src: nil, &block)
  tag.turbo_frame id: name, src: src do
    if block_given?
      yield
    end
  end
end

#rails_mail_turbo_streamObject



21
22
23
# File 'app/helpers/rails_mail/turbo_helper.rb', line 21

def rails_mail_turbo_stream
  TurboStreamBuilder.new
end

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

Raises:

  • (ArgumentError)


11
12
13
14
15
16
17
18
19
# File 'app/helpers/rails_mail/turbo_helper.rb', line 11

def rails_mail_turbo_stream_from(*streamables, **attributes)
  return unless defined?(::ActionCable)

  raise ArgumentError, "streamables can't be blank" unless streamables.any?(&:present?)
  attributes[:channel] = attributes[:channel]&.to_s || "Turbo::StreamsChannel"
  # attributes[:"signed-stream-name"] = Turbo::StreamsChannel.signed_stream_name(streamables)

  tag.turbo_cable_stream_source(**attributes)
end