Skip to content

Commit

Permalink
♻️ Extract coerce_search_arg_to_seqset?
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nevans committed Nov 8, 2024
1 parent 269afc9 commit bad9ec4
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/net/imap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3193,13 +3193,21 @@ def thread_internal(cmd, algorithm, search_keys, charset)

def normalize_searching_criteria(criteria)
return RawData.new(criteria) if criteria.is_a?(String)
criteria.map do |i|
case i
when -1, Range, Array
criteria.map {|i|
if coerce_search_arg_to_seqset?(i)
SequenceSet.new(i)
else
i
end
}
end

def coerce_search_arg_to_seqset?(obj)
case obj
when -1 then true
when Range then true
when Array then true
else false
end
end

Expand Down

0 comments on commit bad9ec4

Please sign in to comment.