From ca06a9ff41c2262d1e16e896d754156cb9352179 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Thu, 25 Feb 2021 11:21:19 -0300 Subject: [PATCH] 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". --- actioncable/lib/action_cable/channel/streams.rb | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/actioncable/lib/action_cable/channel/streams.rb b/actioncable/lib/action_cable/channel/streams.rb index 94e78e7328..3fd0a2b237 100644 --- a/actioncable/lib/action_cable/channel/streams.rb +++ b/actioncable/lib/action_cable/channel/streams.rb @@ -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 model 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