Skip to content

Commit ac10452

Browse files
committed
Remove private call
Below this `private` call we only have a class definition, which as we know it is not affected (`private` only affects methods). We discussed with @dhh the original intention. `ActionCable::RemoteConnections::RemoteConnection` is public interface, it is documented in the API and it is the class of objects returned by the `where` method. Its documentation explains which is its purpose and restricted public interface, so we keep it public and only remove the `private` call.
1 parent 3ae6284 commit ac10452

File tree

1 file changed

+32
-33
lines changed

1 file changed

+32
-33
lines changed

actioncable/lib/action_cable/remote_connections.rb

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -39,45 +39,44 @@ def where(identifier)
3939
RemoteConnection.new(server, identifier)
4040
end
4141

42-
private
43-
# # Action Cable Remote Connection
44-
#
45-
# Represents a single remote connection found via
46-
# `ActionCable.server.remote_connections.where(*)`. Exists solely for the
47-
# purpose of calling #disconnect on that connection.
48-
class RemoteConnection
49-
class InvalidIdentifiersError < StandardError; end
42+
# # Action Cable Remote Connection
43+
#
44+
# Represents a single remote connection found via
45+
# `ActionCable.server.remote_connections.where(*)`. Exists solely for the
46+
# purpose of calling #disconnect on that connection.
47+
class RemoteConnection
48+
class InvalidIdentifiersError < StandardError; end
5049

51-
include Connection::Identification, Connection::InternalChannel
50+
include Connection::Identification, Connection::InternalChannel
5251

53-
def initialize(server, ids)
54-
@server = server
55-
set_identifier_instance_vars(ids)
56-
end
52+
def initialize(server, ids)
53+
@server = server
54+
set_identifier_instance_vars(ids)
55+
end
5756

58-
# Uses the internal channel to disconnect the connection.
59-
def disconnect(reconnect: true)
60-
server.broadcast internal_channel, { type: "disconnect", reconnect: reconnect }
61-
end
57+
# Uses the internal channel to disconnect the connection.
58+
def disconnect(reconnect: true)
59+
server.broadcast internal_channel, { type: "disconnect", reconnect: reconnect }
60+
end
6261

63-
# Returns all the identifiers that were applied to this connection.
64-
redefine_method :identifiers do
65-
server.connection_identifiers
66-
end
62+
# Returns all the identifiers that were applied to this connection.
63+
redefine_method :identifiers do
64+
server.connection_identifiers
65+
end
6766

68-
protected
69-
attr_reader :server
67+
protected
68+
attr_reader :server
7069

71-
private
72-
def set_identifier_instance_vars(ids)
73-
raise InvalidIdentifiersError unless valid_identifiers?(ids)
74-
ids.each { |k, v| instance_variable_set("@#{k}", v) }
75-
end
70+
private
71+
def set_identifier_instance_vars(ids)
72+
raise InvalidIdentifiersError unless valid_identifiers?(ids)
73+
ids.each { |k, v| instance_variable_set("@#{k}", v) }
74+
end
7675

77-
def valid_identifiers?(ids)
78-
keys = ids.keys
79-
identifiers.all? { |id| keys.include?(id) }
80-
end
81-
end
76+
def valid_identifiers?(ids)
77+
keys = ids.keys
78+
identifiers.all? { |id| keys.include?(id) }
79+
end
80+
end
8281
end
8382
end

0 commit comments

Comments
 (0)