From 8323ce312f47a63ea248fe184ec3f12f10b223f9 Mon Sep 17 00:00:00 2001 From: nicholas evans Date: Mon, 1 Jan 2024 21:49:10 -0500 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Forward=20all=20search/uid?= =?UTF-8?q?=5Fsearch=20arguments?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Forward all `#search` and `#uid_search` arguments to `#search_internal`. This simplifies future changes to search parameters. --- lib/net/imap.rb | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/net/imap.rb b/lib/net/imap.rb index fe6fc448..b9e39762 100644 --- a/lib/net/imap.rb +++ b/lib/net/imap.rb @@ -1929,6 +1929,9 @@ def uid_expunge(uid_set) end end + # :call-seq: + # search(criteria, charset = nil) -> result + # # Sends a {SEARCH command [IMAP4rev1 §6.4.4]}[https://www.rfc-editor.org/rfc/rfc3501#section-6.4.4] # to search the mailbox for messages that match the given search +criteria+, # and returns a SearchResult. SearchResult inherits from Array (for @@ -2174,10 +2177,13 @@ def uid_expunge(uid_set) # result = imap.search(["SUBJECT", "hi there", "not", "new"]) # #=> Net::IMAP::SearchResult[1, 6, 7, 8, modseq: 5594] # result.modseq # => 5594 - def search(keys, charset = nil) - return search_internal("SEARCH", keys, charset) + def search(...) + search_internal("SEARCH", ...) end + # :call-seq: + # uid_search(criteria, charset = nil) -> result + # # Sends a {UID SEARCH command [IMAP4rev1 §6.4.8]}[https://www.rfc-editor.org/rfc/rfc3501#section-6.4.8] # to search the mailbox for messages that match the given searching # criteria, and returns unique identifiers (UIDs). @@ -2187,8 +2193,8 @@ def search(keys, charset = nil) # capability has been enabled. # # See #search for documentation of parameters. - def uid_search(keys, charset = nil) - return search_internal("UID SEARCH", keys, charset) + def uid_search(...) + search_internal("UID SEARCH", ...) end # :call-seq: @@ -3117,7 +3123,7 @@ def enforce_logindisabled? end end - def search_internal(cmd, keys, charset) + def search_internal(cmd, keys, charset = nil) keys = normalize_searching_criteria(keys) args = charset ? ["CHARSET", charset, *keys] : keys synchronize do