Class: ActionCable::Channel::Base
- Inherits:
-
Object
- Object
- ActionCable::Channel::Base
- Defined in:
- lib/anycable/rails/actioncable/channel.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#stop_streams ⇒ Object
readonly
Returns the value of attribute stop_streams.
Instance Method Summary collapse
- #delegate_connection_identifiers ⇒ Object
- #handle_action(data) ⇒ Object
- #handle_subscribe ⇒ Object
- #handle_unsubscribe ⇒ Object
- #stop_all_streams ⇒ Object
- #stop_streams? ⇒ Boolean
- #stream_from(broadcasting, callback = nil, coder: nil) ⇒ Object
- #streams ⇒ Object
- #subscribe_to_channel ⇒ Object
Instance Attribute Details
#stop_streams ⇒ Object (readonly)
Returns the value of attribute stop_streams.
23 24 25 |
# File 'lib/anycable/rails/actioncable/channel.rb', line 23 def stop_streams @stop_streams end |
Instance Method Details
#delegate_connection_identifiers ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/anycable/rails/actioncable/channel.rb', line 42 def delegate_connection_identifiers connection.identifiers.each do |identifier| define_singleton_method(identifier) do connection.fetch_identifier(identifier) end end end |
#handle_action(data) ⇒ Object
19 20 21 |
# File 'lib/anycable/rails/actioncable/channel.rb', line 19 def handle_action(data) perform_action ActiveSupport::JSON.decode(data) end |
#handle_subscribe ⇒ Object
7 |
# File 'lib/anycable/rails/actioncable/channel.rb', line 7 alias handle_subscribe subscribe_to_channel |
#handle_unsubscribe ⇒ Object
15 16 17 |
# File 'lib/anycable/rails/actioncable/channel.rb', line 15 def handle_unsubscribe connection.subscriptions.remove_subscription(self) end |
#stop_all_streams ⇒ Object
30 31 32 |
# File 'lib/anycable/rails/actioncable/channel.rb', line 30 def stop_all_streams @stop_streams = true end |
#stop_streams? ⇒ Boolean
38 39 40 |
# File 'lib/anycable/rails/actioncable/channel.rb', line 38 def stop_streams? stop_streams == true end |
#stream_from(broadcasting, callback = nil, coder: nil) ⇒ Object
25 26 27 28 |
# File 'lib/anycable/rails/actioncable/channel.rb', line 25 def stream_from(broadcasting, callback = nil, coder: nil) raise ArgumentError('Unsupported') if callback.present? || coder.present? || block_given? streams << broadcasting end |
#streams ⇒ Object
34 35 36 |
# File 'lib/anycable/rails/actioncable/channel.rb', line 34 def streams @streams ||= [] end |
#subscribe_to_channel ⇒ Object
11 12 13 |
# File 'lib/anycable/rails/actioncable/channel.rb', line 11 def subscribe_to_channel # noop end |