From 386ab893f68ee8344674f7fd2a248dcae9f5d2b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Thu, 23 Sep 2021 19:23:27 -0400 Subject: [PATCH] Use regular memoization `connection_gid` always return something so we don't need to use `defined?`. --- actioncable/lib/action_cable/channel/test_case.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/actioncable/lib/action_cable/channel/test_case.rb b/actioncable/lib/action_cable/channel/test_case.rb index 6062eda198..3c75a63def 100644 --- a/actioncable/lib/action_cable/channel/test_case.rb +++ b/actioncable/lib/action_cable/channel/test_case.rb @@ -64,17 +64,13 @@ module ActionCable end def connection_identifier - unless defined? @connection_identifier - @connection_identifier = connection_gid identifiers.filter_map { |id| send(id.to_sym) if id } - end - - @connection_identifier + @connection_identifier ||= connection_gid(identifiers.filter_map { |id| send(id.to_sym) if id }) end private def connection_gid(ids) ids.map do |o| - if o.respond_to? :to_gid_param + if o.respond_to?(:to_gid_param) o.to_gid_param else o.to_s