Skip to content

Commit bad9ec4

Browse files
committed
♻️ Extract coerce_search_arg_to_seqset?
This will be useful later, for recursively inspecting arrays. Also, the three different cases are split up, because we'll probably add extra limitations on `Range` and `Array` in a different PR.
1 parent 269afc9 commit bad9ec4

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

lib/net/imap.rb

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3193,13 +3193,21 @@ def thread_internal(cmd, algorithm, search_keys, charset)
31933193

31943194
def normalize_searching_criteria(criteria)
31953195
return RawData.new(criteria) if criteria.is_a?(String)
3196-
criteria.map do |i|
3197-
case i
3198-
when -1, Range, Array
3196+
criteria.map {|i|
3197+
if coerce_search_arg_to_seqset?(i)
31993198
SequenceSet.new(i)
32003199
else
32013200
i
32023201
end
3202+
}
3203+
end
3204+
3205+
def coerce_search_arg_to_seqset?(obj)
3206+
case obj
3207+
when -1 then true
3208+
when Range then true
3209+
when Array then true
3210+
else false
32033211
end
32043212
end
32053213

0 commit comments

Comments
 (0)