Class: Motion::Callback
- Inherits:
-
Object
- Object
- Motion::Callback
- Defined in:
- lib/motion/callback.rb
Instance Attribute Summary collapse
-
#broadcast ⇒ Object
readonly
Returns the value of attribute broadcast.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #call(message = nil) ⇒ Object
-
#initialize(component, method) ⇒ Callback
constructor
A new instance of Callback.
Constructor Details
#initialize(component, method) ⇒ Callback
Returns a new instance of Callback.
20 21 22 23 24 |
# File 'lib/motion/callback.rb', line 20 def initialize(component, method) @broadcast = self.class.broadcast_for(component, method) component.stream_from(broadcast, method) end |
Instance Attribute Details
#broadcast ⇒ Object (readonly)
Returns the value of attribute broadcast.
7 8 9 |
# File 'lib/motion/callback.rb', line 7 def broadcast @broadcast end |
Class Method Details
.broadcast_for(component, method) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/motion/callback.rb', line 12 def self.broadcast_for(component, method) [ NAMESPACE, component.stable_instance_identifier_for_callbacks, method ].join(":") end |
Instance Method Details
#==(other) ⇒ Object
26 27 28 29 |
# File 'lib/motion/callback.rb', line 26 def ==(other) other.is_a?(Callback) && other.broadcast == broadcast end |
#call(message = nil) ⇒ Object
31 32 33 |
# File 'lib/motion/callback.rb', line 31 def call( = nil) ActionCable.server.broadcast(broadcast, ) end |