Skip to content

Commit 8323ce3

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 a90782d commit 8323ce3

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

lib/net/imap.rb

Lines changed: 11 additions & 5 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 search +criteria+,
19341937
# and returns a SearchResult. SearchResult inherits from Array (for
@@ -2174,10 +2177,13 @@ def uid_expunge(uid_set)
21742177
# result = imap.search(["SUBJECT", "hi there", "not", "new"])
21752178
# #=> Net::IMAP::SearchResult[1, 6, 7, 8, modseq: 5594]
21762179
# result.modseq # => 5594
2177-
def search(keys, charset = nil)
2178-
return search_internal("SEARCH", keys, charset)
2180+
def search(...)
2181+
search_internal("SEARCH", ...)
21792182
end
21802183

2184+
# :call-seq:
2185+
# uid_search(criteria, charset = nil) -> result
2186+
#
21812187
# Sends a {UID SEARCH command [IMAP4rev1 §6.4.8]}[https://www.rfc-editor.org/rfc/rfc3501#section-6.4.8]
21822188
# to search the mailbox for messages that match the given searching
21832189
# criteria, and returns unique identifiers (<tt>UID</tt>s).
@@ -2187,8 +2193,8 @@ def search(keys, charset = nil)
21872193
# capability has been enabled.
21882194
#
21892195
# See #search for documentation of parameters.
2190-
def uid_search(keys, charset = nil)
2191-
return search_internal("UID SEARCH", keys, charset)
2196+
def uid_search(...)
2197+
search_internal("UID SEARCH", ...)
21922198
end
21932199

21942200
# :call-seq:
@@ -3117,7 +3123,7 @@ def enforce_logindisabled?
31173123
end
31183124
end
31193125

3120-
def search_internal(cmd, keys, charset)
3126+
def search_internal(cmd, keys, charset = nil)
31213127
keys = normalize_searching_criteria(keys)
31223128
args = charset ? ["CHARSET", charset, *keys] : keys
31233129
synchronize do

0 commit comments

Comments
 (0)