Skip to content

Commit cb444ff

Browse files
committed
♻️ Forward all search/uid_search arguments
Forward all `#search` and `#uid_search` arguments to `#search_internal`. This simplifies future changes to search parameters.
1 parent d723c6d commit cb444ff

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

lib/net/imap.rb

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1929,6 +1929,9 @@ def uid_expunge(uid_set)
19291929
end
19301930
end
19311931

1932+
# :call-seq:
1933+
# search(criteria, charset = nil) -> result
1934+
#
19321935
# Sends a {SEARCH command [IMAP4rev1 §6.4.4]}[https://www.rfc-editor.org/rfc/rfc3501#section-6.4.4]
19331936
# to search the mailbox for messages that match the given searching
19341937
# criteria, and returns message sequence numbers. +keys+ can either be a
@@ -1996,10 +1999,13 @@ def uid_expunge(uid_set)
19961999
# result = imap.search(["SUBJECT", "hi there", "not", "new")
19972000
# #=> Net::IMAP::SearchResult[1, 6, 7, 8, modseq: 5594]
19982001
# result.modseq # => 5594
1999-
def search(keys, charset = nil)
2000-
return search_internal("SEARCH", keys, charset)
2002+
def search(...)
2003+
search_internal("SEARCH", ...)
20012004
end
20022005

2006+
# :call-seq:
2007+
# uid_search(criteria, charset = nil) -> result
2008+
#
20032009
# Sends a {UID SEARCH command [IMAP4rev1 §6.4.8]}[https://www.rfc-editor.org/rfc/rfc3501#section-6.4.8]
20042010
# to search the mailbox for messages that match the given searching
20052011
# criteria, and returns unique identifiers (<tt>UID</tt>s).
@@ -2008,7 +2014,7 @@ def search(keys, charset = nil)
20082014
# backward compatibility) but adds SearchResult#modseq when the +CONDSTORE+
20092015
# capability has been enabled.
20102016
#
2011-
# See #search for documentation of search criteria.
2017+
# See #search for documentation of parameters.
20122018
def uid_search(keys, charset = nil)
20132019
return search_internal("UID SEARCH", keys, charset)
20142020
end
@@ -2939,7 +2945,7 @@ def enforce_logindisabled?
29392945
end
29402946
end
29412947

2942-
def search_internal(cmd, keys, charset)
2948+
def search_internal(cmd, keys, charset = nil)
29432949
keys = normalize_searching_criteria(keys)
29442950
args = charset ? ["CHARSET", charset, *keys] : keys
29452951
synchronize do

0 commit comments

Comments
 (0)