Class: CableReady::Channel
- Inherits:
-
OperationBuilder
- Object
- OperationBuilder
- CableReady::Channel
- Defined in:
- lib/cable_ready/channel.rb
Instance Attribute Summary collapse
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
Attributes inherited from OperationBuilder
#previous_selector, #previous_xpath
Instance Method Summary collapse
- #broadcast(clear: true) ⇒ Object
- #broadcast_later(clear: true, queue: nil) ⇒ Object
- #broadcast_later_to(model, clear: true, queue: nil) ⇒ Object
- #broadcast_to(model, clear: true) ⇒ Object
Methods inherited from OperationBuilder
#add_operation_method, #apply!, finalizer_for, #initialize, #operations_payload, #reset!, #to_json
Methods included from Identifiable
Constructor Details
This class inherits a constructor from CableReady::OperationBuilder
Instance Attribute Details
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
5 6 7 |
# File 'lib/cable_ready/channel.rb', line 5 def identifier @identifier end |
Instance Method Details
#broadcast(clear: true) ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/cable_ready/channel.rb', line 7 def broadcast(clear: true) raise("Action Cable must be enabled to use broadcast") unless defined?(ActionCable) clients_received = ActionCable.server.broadcast identifier, { "cableReady" => true, "operations" => operations_payload, "version" => CableReady::VERSION } reset! if clear clients_received end |
#broadcast_later(clear: true, queue: nil) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/cable_ready/channel.rb', line 29 def broadcast_later(clear: true, queue: nil) raise("Action Cable must be enabled to use broadcast_later") unless defined?(ActionCable) CableReady::BroadcastJob .set(queue: queue ? queue.to_sym : CableReady.config.broadcast_job_queue) .perform_later(identifier: identifier, operations: operations_payload) reset! if clear end |
#broadcast_later_to(model, clear: true, queue: nil) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/cable_ready/channel.rb', line 37 def broadcast_later_to(model, clear: true, queue: nil) raise("Action Cable must be enabled to use broadcast_later_to") unless defined?(ActionCable) CableReady::BroadcastJob .set(queue: queue ? queue.to_sym : CableReady.config.broadcast_job_queue) .perform_later(identifier: identifier.name, operations: operations_payload, model: model) reset! if clear end |
#broadcast_to(model, clear: true) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/cable_ready/channel.rb', line 18 def broadcast_to(model, clear: true) raise("Action Cable must be enabled to use broadcast_to") unless defined?(ActionCable) clients_received = identifier.broadcast_to model, { "cableReady" => true, "operations" => operations_payload, "version" => CableReady::VERSION } reset! if clear clients_received end |