module OpenUI::Rails::Stream::Transports

Transport wrappers for {Broadcaster}. Each responds to ‘#broadcast(envelope)` and is intentionally thin: sequencing, coalescing and size limits live in {Bridge}, not here.

Public Instance Methods

build(name, **options) click to toggle source

Build a transport from a configured name.

@param name [Symbol] :action_cable, :turbo / :turbo_streams or :memory

@param options [Hash] forwarded to the transport constructor

@return [ActionCable, TurboStreams, Memory]

@raise [ConfigurationError] when the name is unsupported

# File lib/openui/rails/stream/transports.rb, line 25
def build(name, **options)
  case name.to_sym
  when :action_cable
    ActionCable.new(options.delete(:stream_name), **options)
  when :turbo, :turbo_streams
    TurboStreams.new(options.delete(:stream), **options)
  when :memory
    Memory.new(**options)
  else
    raise ConfigurationError,
          "unsupported transport #{name.inspect}; expected one of [:action_cable, :turbo, :memory]"
  end
end