Module: Motion::Component::Broadcasts::ModuleFunctions

Included in:
Motion::Component::Broadcasts
Defined in:
lib/motion/component/broadcasts.rb

Overview

Analogous to ‘module_function` (available on both class and instance)

Instance Method Summary collapse

Instance Method Details

#broadcastsObject



37
38
39
# File 'lib/motion/component/broadcasts.rb', line 37

def broadcasts
  _broadcast_handlers.keys
end

#stop_streaming_for(model) ⇒ Object



33
34
35
# File 'lib/motion/component/broadcasts.rb', line 33

def stop_streaming_for(model)
  stop_streaming_from(broadcasting_for(model))
end

#stop_streaming_from(broadcast) ⇒ Object



24
25
26
27
# File 'lib/motion/component/broadcasts.rb', line 24

def stop_streaming_from(broadcast)
  self._broadcast_handlers =
    _broadcast_handlers.except(broadcast.to_s).freeze
end

#stream_for(model, handler) ⇒ Object



29
30
31
# File 'lib/motion/component/broadcasts.rb', line 29

def stream_for(model, handler)
  stream_from(broadcasting_for(model), handler)
end

#stream_from(broadcast, handler) ⇒ Object



19
20
21
22
# File 'lib/motion/component/broadcasts.rb', line 19

def stream_from(broadcast, handler)
  self._broadcast_handlers =
    _broadcast_handlers.merge(broadcast.to_s => handler.to_sym).freeze
end