Skip to content

Commit c5245d4

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 a445c8c commit c5245d4

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
@@ -2020,10 +2023,13 @@ def uid_expunge(uid_set)
20202023
# result = imap.search(["SUBJECT", "hi there", "not", "new"])
20212024
# #=> Net::IMAP::SearchResult[1, 6, 7, 8, modseq: 5594]
20222025
# result.modseq # => 5594
2023-
def search(keys, charset = nil)
2024-
return search_internal("SEARCH", keys, charset)
2026+
def search(...)
2027+
search_internal("SEARCH", ...)
20252028
end
20262029

2030+
# :call-seq:
2031+
# uid_search(criteria, charset = nil) -> result
2032+
#
20272033
# Sends a {UID SEARCH command [IMAP4rev1 §6.4.8]}[https://www.rfc-editor.org/rfc/rfc3501#section-6.4.8]
20282034
# to search the mailbox for messages that match the given searching
20292035
# criteria, and returns unique identifiers (<tt>UID</tt>s).
@@ -2033,8 +2039,8 @@ def search(keys, charset = nil)
20332039
# capability has been enabled.
20342040
#
20352041
# See #search for documentation of parameters.
2036-
def uid_search(keys, charset = nil)
2037-
return search_internal("UID SEARCH", keys, charset)
2042+
def uid_search(...)
2043+
search_internal("UID SEARCH", ...)
20382044
end
20392045

20402046
# :call-seq:
@@ -2963,7 +2969,7 @@ def enforce_logindisabled?
29632969
end
29642970
end
29652971

2966-
def search_internal(cmd, keys, charset)
2972+
def search_internal(cmd, keys, charset = nil)
29672973
keys = normalize_searching_criteria(keys)
29682974
args = charset ? ["CHARSET", charset, *keys] : keys
29692975
synchronize do

0 commit comments

Comments
 (0)