Skip to content

Commit

Permalink
Refactor to use model instead of record as argument in Action Cable
Browse files Browse the repository at this point in the history
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".
  • Loading branch information
carlosantoniodasilva committed Feb 25, 2021
1 parent a7e8e1a commit ca06a9f
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions actioncable/lib/action_cable/channel/streams.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,11 @@ def stop_all_streams
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
Expand Down

0 comments on commit ca06a9f

Please sign in to comment.