Module: Rage::Cable::RemoteDisconnect::ClassMethods
- Defined in:
- lib/rage/cable/remote_disconnect.rb
Instance Method Summary collapse
-
#disconnect(protocol_options: nil, **identified_by) ⇒ Object
Disconnect all connections matching the specified identifier.
Instance Method Details
#disconnect(protocol_options: nil, **identified_by) ⇒ Object
Disconnect all connections matching the specified identifier.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/rage/cable/remote_disconnect.rb', line 32 def disconnect(protocol_options: nil, **identified_by) raise ArgumentError, "An identifier must be provided" if identified_by.empty? raise ArgumentError, "Only one identifier can be provided" if identified_by.size > 1 id_pair = identified_by.first unless __identifiers&.include?(id_pair[0]) raise ArgumentError, "Unknown identifier: #{id_pair[0]}" end = if raise ArgumentError, "protocol_options must be a Hash" unless .is_a?(Hash) .to_json else "" end Rage::PubSub.publish(, topic: ["rage", name, id_pair]) end |