From dac3dde9e855f54db368318eb5a02d827dbf7036 Mon Sep 17 00:00:00 2001 From: Joshua Pinter Date: Fri, 26 Jan 2024 10:53:01 -0500 Subject: [PATCH] Do not remove empty values in a non-empty Array. FIXME: Make this an option or configurable. --- lib/searchlight/options.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/searchlight/options.rb b/lib/searchlight/options.rb index 7a0199d..d0df779 100644 --- a/lib/searchlight/options.rb +++ b/lib/searchlight/options.rb @@ -18,7 +18,8 @@ def self.excluding_empties(input) output[key] = value.reject { |_, v| empty?(v) } end if value.instance_of?(Array) - output[key] = value.reject { |v| empty?(v) } + # output[key] = value.reject { |v| empty?(v) } # Do not remove empty values in a non-empty Array. FIXME: Make this an option or configurable. + output[key] = nil if output[key].all?(&:blank?) # If Array is entirely empty (i.e. `nil` or empty Strings only) then remove it. end end output.reject { |_, value| empty?(value) }