In the documentation, Connection section of Ruby on Rails Guide on Action Cable , the word 'delegate' is used and I don't know what they mean. Here's the code they are referring to in the section:
# app/channels/application_cable/connection.rb
module ApplicationCable
class Connection < ActionCable::Connection::Base
identified_by :current_user
def connect
self.current_user = find_verified_user
end
private
def find_verified_user
if current_user = User.find_by(id: cookies.signed[:user_id])
current_user
else
reject_unauthorized_connection
end
end
end
end
Here's the explanation where the explanation is given:
Here identified_by is a connection identifier that can be used to find the specific connection later. Note that anything marked as an identifier will automatically create a delegate by the same name on any channel instances created off the connection.
When they say off the connection, do they mean that the word current_user
will refer to the same client in an entirely different connection?