From 1fe289d22f91ce86474e32ac6a438db2eeec548b Mon Sep 17 00:00:00 2001 From: Alexander Repnikov Date: Tue, 19 Dec 2023 18:39:01 +0100 Subject: [PATCH] Strict value is not null coalesced from a false value Issue 28: https://github.com/eventide-project/messaging/issues/28 --- lib/messaging/handle.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/messaging/handle.rb b/lib/messaging/handle.rb index dc21855..465b210 100644 --- a/lib/messaging/handle.rb +++ b/lib/messaging/handle.rb @@ -159,9 +159,9 @@ def message_registry end end -## Can't null-coalesce here. It's a boolean. Use expanded form of `if` block - Scott, Mon Oct 16 2023 def strict - @strict ||= Defaults.strict + @strict = Defaults.strict if @strict.nil? + @strict end alias :strict? :strict @@ -174,7 +174,7 @@ def call(message_or_message_data, strict: nil) end def handle_message(message, strict: nil) - strict ||= self.strict? + strict = self.strict? if strict.nil? handler_logger.trace(tags: [:dispatch, :message]) { "Dispatching message (Message class: #{message.class.name})" } handler_logger.trace(tags: [:data, :message]) { message.pretty_inspect } @@ -202,7 +202,7 @@ def handle_message(message, strict: nil) end def handle_message_data(message_data, strict: nil) - strict ||= self.strict? + strict = self.strict? if strict.nil? handler_logger.trace(tags: [:dispatch, :message_data]) { "Dispatching message data (Type: #{message_data.type})" } handler_logger.trace(tags: [:data, :message_data]) { message_data.pretty_inspect }