Refactor to use `model` instead of `record` as argument in Action Cable

We refer to `model` elsewhere in Action Cable's  implementation, so use
the same in `stream_or_reject_for` as well to keep the consistency.

Simplify the docs for the method to remove the usage "intention"
(that's not up to us) and mention it rejects the "subscription", not
the "connection".
This commit is contained in:
Carlos Antonio da Silva 2021-02-25 11:21:19 -03:00
parent a7e8e1a6d1
commit ca06a9ff41
1 changed files with 5 additions and 7 deletions

View File

@ -124,13 +124,11 @@ module ActionCable
end.clear
end
# Calls stream_for if record is present, otherwise calls reject.
# This method is intended to be called when you're looking
# for a record based on a parameter, if its found it will start
# streaming. If the record is nil then it will reject the connection.
def stream_or_reject_for(record)
if record
stream_for record
# Calls stream_for with the given <tt>model</tt> if it's present to start streaming,
# otherwise rejects the subscription.
def stream_or_reject_for(model)
if model
stream_for model
else
reject
end