Skip to content

Commit fb82ed0

Browse files
committed
🎨 Move response handlers after IMAP commands
1 parent 4c9bf81 commit fb82ed0

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

lib/net/imap.rb

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1845,28 +1845,6 @@ def uid_sort(sort_keys, search_keys, charset)
18451845
return sort_internal("UID SORT", sort_keys, search_keys, charset)
18461846
end
18471847

1848-
# Adds a response handler. For example, to detect when
1849-
# the server sends a new EXISTS response (which normally
1850-
# indicates new messages being added to the mailbox),
1851-
# add the following handler after selecting the
1852-
# mailbox:
1853-
#
1854-
# imap.add_response_handler { |resp|
1855-
# if resp.kind_of?(Net::IMAP::UntaggedResponse) and resp.name == "EXISTS"
1856-
# puts "Mailbox now has #{resp.data} messages"
1857-
# end
1858-
# }
1859-
#
1860-
def add_response_handler(handler = nil, &block)
1861-
raise ArgumentError, "two Procs are passed" if handler && block
1862-
@response_handlers.push(block || handler)
1863-
end
1864-
1865-
# Removes the response handler.
1866-
def remove_response_handler(handler)
1867-
@response_handlers.delete(handler)
1868-
end
1869-
18701848
# Sends a {THREAD command [RFC5256 §3]}[https://www.rfc-editor.org/rfc/rfc5256#section-3]
18711849
# to search a mailbox and return message sequence numbers in threaded
18721850
# format, as a ThreadMember tree. +search_keys+ are interpreted the same as
@@ -1970,6 +1948,28 @@ def idle_done
19701948
end
19711949
end
19721950

1951+
# Adds a response handler. For example, to detect when
1952+
# the server sends a new EXISTS response (which normally
1953+
# indicates new messages being added to the mailbox),
1954+
# add the following handler after selecting the
1955+
# mailbox:
1956+
#
1957+
# imap.add_response_handler { |resp|
1958+
# if resp.kind_of?(Net::IMAP::UntaggedResponse) and resp.name == "EXISTS"
1959+
# puts "Mailbox now has #{resp.data} messages"
1960+
# end
1961+
# }
1962+
#
1963+
def add_response_handler(handler = nil, &block)
1964+
raise ArgumentError, "two Procs are passed" if handler && block
1965+
@response_handlers.push(block || handler)
1966+
end
1967+
1968+
# Removes the response handler.
1969+
def remove_response_handler(handler)
1970+
@response_handlers.delete(handler)
1971+
end
1972+
19731973
private
19741974

19751975
CRLF = "\r\n" # :nodoc:

0 commit comments

Comments
 (0)