Sha256: 206bea7d46de4aaab6ec3459957fba6a1e94fb0a41f0f23ffb167986ae5743ad

Contents?: true

Size: 944 Bytes

Versions: 4

Compression:

Stored size: 944 Bytes

Contents

# frozen_string_literal: true

module StimulusReflex
  class CableReadyChannels
    delegate :[], to: "cable_ready_channels"

    def initialize(reflex)
      @stream_name = reflex.stream_name
      @id = reflex.id
      CableReady.config.add_operation_name(:stimulus_reflex_version_mismatch)
    end

    def cable_ready_channels
      CableReady::Channels.instance
    end

    def stimulus_reflex_channel
      CableReady::Channels.instance[@stream_name]
    end

    def method_missing(name, *args)
      if stimulus_reflex_channel.respond_to?(name)
        if (options = args.find_index { |a| a.is_a? Hash })
          args[options][:reflex_id] = @id
        elsif args.any?
          args << {reflex_id: @id}
        end
        return stimulus_reflex_channel.public_send(name, *args)
      end
      super
    end

    def respond_to_missing?(name, include_all)
      stimulus_reflex_channel.respond_to?(name) || super
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
stimulus_reflex-3.5.0.rc4 lib/stimulus_reflex/cable_ready_channels.rb
stimulus_reflex-3.5.0.rc3 lib/stimulus_reflex/cable_ready_channels.rb
stimulus_reflex-3.5.0.rc2 lib/stimulus_reflex/cable_ready_channels.rb
stimulus_reflex-3.5.0.rc1 lib/stimulus_reflex/cable_ready_channels.rb