Skip to content

Commit 2ee45e8

Browse files
committed
Use Object#tap instead of #returning (#6887).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4406 e93f8b46-1217-0410-a6f0-8f06a7374b81
1 parent c4a2183 commit 2ee45e8

File tree

6 files changed

+8
-8
lines changed

6 files changed

+8
-8
lines changed

lib/redmine/hook.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def clear_listeners_instances
5757
# Calls a hook.
5858
# Returns the listeners response.
5959
def call_hook(hook, context={})
60-
returning [] do |response|
60+
[].tap do |response|
6161
hls = hook_listeners(hook)
6262
if hls.any?
6363
hls.each {|listener| response << listener.send(hook, context)}

lib/redmine/menu_manager.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,13 +192,13 @@ def render_menu_node(node, project=nil)
192192
def render_menu_node_with_children(node, project=nil)
193193
caption, url, selected = extract_node_details(node, project)
194194

195-
html = returning [] do |html|
195+
html = [].tap do |html|
196196
html << '<li>'
197197
# Parent
198198
html << render_single_menu_node(node, caption, url, selected)
199199

200200
# Standard children
201-
standard_children_list = returning "" do |child_html|
201+
standard_children_list = "".tap do |child_html|
202202
node.children.each do |child|
203203
child_html << render_menu_node(child, project)
204204
end
@@ -219,7 +219,7 @@ def render_menu_node_with_children(node, project=nil)
219219
def render_unattached_children_menu(node, project)
220220
return nil unless node.child_menus
221221

222-
returning "" do |child_html|
222+
"".tap do |child_html|
223223
unattached_children = node.child_menus.call(project)
224224
# Tree nodes support #each so we need to do object detection
225225
if unattached_children.is_a? Array

test/exemplars/project_exemplar.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def self.next_identifier_from_object_daddy
1818
end
1919

2020
def self.all_modules
21-
returning [] do |modules|
21+
[].tap do |modules|
2222
Redmine::AccessControl.available_project_modules.each do |name|
2323
modules << EnabledModule.new(:name => name.to_s)
2424
end

vendor/plugins/awesome_nested_set/lib/awesome_nested_set.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def all_roots_valid?
154154
def each_root_valid?(roots_to_validate)
155155
left = right = 0
156156
roots_to_validate.all? do |root|
157-
returning(root.left > left && root.right > right) do
157+
(root.left > left && root.right > right).tap do
158158
left = root.left
159159
right = root.right
160160
end

vendor/plugins/engines/generators/plugin_migration/plugin_migration_generator.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def get_plugins_to_migrate(plugin_names)
7676
# plugin names involved is shorter than 230 characters that one will be
7777
# used. Otherwise a shorter name will be returned.
7878
def build_migration_name
79-
returning descriptive_migration_name do |name|
79+
descriptive_migration_name.tap do |name|
8080
name.replace short_migration_name if name.length > MAX_FILENAME_LENGTH
8181
end
8282
end

vendor/plugins/gravatar/lib/gravatar.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def gravatar_url(email, options={})
7171
email_hash = Digest::MD5.hexdigest(email)
7272
options = DEFAULT_OPTIONS.merge(options)
7373
options[:default] = CGI::escape(options[:default]) unless options[:default].nil?
74-
returning gravatar_api_url(email_hash, options.delete(:ssl)) do |url|
74+
gravatar_api_url(email_hash, options.delete(:ssl)).tap do |url|
7575
opts = []
7676
[:rating, :size, :default].each do |opt|
7777
unless options[opt].nil?

0 commit comments

Comments
 (0)