class ActionCable::RemoteConnections::RemoteConnection
Represents a single remote connection found via
ActionCable.server.remote_connections.where(*)
. Exists solely
for the purpose of calling disconnect on that
connection.
Attributes
server[R]
Public Class Methods
new(server, ids)
click to toggle source
# File lib/action_cable/remote_connections.rb, line 37 def initialize(server, ids) @server = server set_identifier_instance_vars(ids) end
Public Instance Methods
disconnect()
click to toggle source
Uses the internal channel to disconnect the connection.
# File lib/action_cable/remote_connections.rb, line 43 def disconnect server.broadcast internal_channel, type: 'disconnect' end
identifiers()
click to toggle source
Returns all the identifiers that were applied to this connection.
# File lib/action_cable/remote_connections.rb, line 48 def identifiers server.connection_identifiers end
Private Instance Methods
set_identifier_instance_vars(ids)
click to toggle source
# File lib/action_cable/remote_connections.rb, line 55 def set_identifier_instance_vars(ids) raise InvalidIdentifiersError unless valid_identifiers?(ids) ids.each { |k,v| instance_variable_set("@#{k}", v) } end
valid_identifiers?(ids)
click to toggle source
# File lib/action_cable/remote_connections.rb, line 60 def valid_identifiers?(ids) keys = ids.keys identifiers.all? { |id| keys.include?(id) } end