Skip to content

Commit b7b7fb2

Browse files
committed
Use block parameters instead of using 'yield'
1 parent 81ca133 commit b7b7fb2

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

lib/imap/backup/account/folder_mapper.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ def initialize(
3232
# @yieldparam serializer [Serializer] the folder's serializer
3333
# @yieldparam folder [Account::Folder] the online folder
3434
# @return [Enumerator, void]
35-
def each
35+
def each(&block)
3636
return enum_for(:each) if !block_given?
3737

3838
glob = File.join(source_local_path, "**", "*.imap")
3939
Pathname.glob(glob) do |path|
4040
name = source_folder_name(path)
4141
serializer = Serializer.new(source_local_path, name)
4242
folder = destination_folder_for_path(name)
43-
yield serializer, folder
43+
block.call(serializer, folder)
4444
end
4545
end
4646

lib/imap/backup/logger.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ def self.setup_logging(options = {})
5151
# Wraps a block, filtering output to standard error,
5252
# hidng passwords and outputs the results to standard out
5353
# @return [void]
54-
def self.sanitize_stderr
54+
def self.sanitize_stderr(&block)
5555
sanitizer = Text::Sanitizer.new($stdout)
5656
previous_stderr = $stderr
5757
$stderr = sanitizer
58-
yield
58+
block.call
5959
ensure
6060
sanitizer.flush
6161
$stderr = previous_stderr

lib/imap/backup/retry_on_error.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ module RetryOnError
1313
# @param on_error [Proc] a block to call when an error occurs
1414
# @raise any error ocurring more than `limit` times
1515
# @return the result of any successful completion of the block
16-
def retry_on_error(errors:, limit: 10, on_error: nil)
16+
def retry_on_error(errors:, limit: 10, on_error: nil, &block)
1717
tries ||= 1
18-
yield
18+
block.call
1919
rescue *errors => e
2020
if tries < limit
2121
message = "#{e}, attempt #{tries} of #{limit}"

lib/imap/backup/serializer/message_enumerator.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ def initialize(imap:)
1414
# @param uids [Array<Integer>] the message UIDs of the messages to iterate over
1515
# @yieldparam message [Serializer::Message]
1616
# @return [void]
17-
def run(uids:)
17+
def run(uids:, &block)
1818
uids.each do |uid_maybe_string|
1919
uid = uid_maybe_string.to_i
2020
message = imap.get(uid)
2121

2222
next if !message
2323

24-
yield message
24+
block.call(message)
2525
end
2626
end
2727

spec/unit/uploader_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ module Imap::Backup
3737
instance_double(Imap::Backup::Serializer::Message, uid: 1, body: "body", flags: [:MyFlag])
3838
end
3939

40-
def message_enumerator
41-
yield missing_message
40+
def message_enumerator(&block)
41+
block.call(missing_message)
4242
end
4343

4444
it "creates the folder" do

0 commit comments

Comments
 (0)