Class: StimulusReflex::CableReadyChannels

Inherits:
Object
  • Object
show all
Defined in:
lib/stimulus_reflex/cable_ready_channels.rb

Instance Method Summary collapse

Constructor Details

#initialize(reflex) ⇒ CableReadyChannels

Returns a new instance of CableReadyChannels.



7
8
9
10
11
# File 'lib/stimulus_reflex/cable_ready_channels.rb', line 7

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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/stimulus_reflex/cable_ready_channels.rb', line 21

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

Instance Method Details

#cable_ready_channelsObject



13
14
15
# File 'lib/stimulus_reflex/cable_ready_channels.rb', line 13

def cable_ready_channels
  CableReady::Channels.instance
end

#respond_to_missing?(name, include_all) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/stimulus_reflex/cable_ready_channels.rb', line 33

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

#stimulus_reflex_channelObject



17
18
19
# File 'lib/stimulus_reflex/cable_ready_channels.rb', line 17

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