##// END OF EJS Templates
Use Object#tap instead of #returning (#6887)....
Jean-Philippe Lang -
r4292:2ee45e8cac90
parent child
Show More
@@ -57,7 +57,7 module Redmine
57 # Calls a hook.
57 # Calls a hook.
58 # Returns the listeners response.
58 # Returns the listeners response.
59 def call_hook(hook, context={})
59 def call_hook(hook, context={})
60 returning [] do |response|
60 [].tap do |response|
61 hls = hook_listeners(hook)
61 hls = hook_listeners(hook)
62 if hls.any?
62 if hls.any?
63 hls.each {|listener| response << listener.send(hook, context)}
63 hls.each {|listener| response << listener.send(hook, context)}
@@ -192,13 +192,13 module Redmine
192 def render_menu_node_with_children(node, project=nil)
192 def render_menu_node_with_children(node, project=nil)
193 caption, url, selected = extract_node_details(node, project)
193 caption, url, selected = extract_node_details(node, project)
194
194
195 html = returning [] do |html|
195 html = [].tap do |html|
196 html << '<li>'
196 html << '<li>'
197 # Parent
197 # Parent
198 html << render_single_menu_node(node, caption, url, selected)
198 html << render_single_menu_node(node, caption, url, selected)
199
199
200 # Standard children
200 # Standard children
201 standard_children_list = returning "" do |child_html|
201 standard_children_list = "".tap do |child_html|
202 node.children.each do |child|
202 node.children.each do |child|
203 child_html << render_menu_node(child, project)
203 child_html << render_menu_node(child, project)
204 end
204 end
@@ -219,7 +219,7 module Redmine
219 def render_unattached_children_menu(node, project)
219 def render_unattached_children_menu(node, project)
220 return nil unless node.child_menus
220 return nil unless node.child_menus
221
221
222 returning "" do |child_html|
222 "".tap do |child_html|
223 unattached_children = node.child_menus.call(project)
223 unattached_children = node.child_menus.call(project)
224 # Tree nodes support #each so we need to do object detection
224 # Tree nodes support #each so we need to do object detection
225 if unattached_children.is_a? Array
225 if unattached_children.is_a? Array
@@ -18,7 +18,7 class Project < ActiveRecord::Base
18 end
18 end
19
19
20 def self.all_modules
20 def self.all_modules
21 returning [] do |modules|
21 [].tap do |modules|
22 Redmine::AccessControl.available_project_modules.each do |name|
22 Redmine::AccessControl.available_project_modules.each do |name|
23 modules << EnabledModule.new(:name => name.to_s)
23 modules << EnabledModule.new(:name => name.to_s)
24 end
24 end
@@ -154,7 +154,7 module CollectiveIdea #:nodoc:
154 def each_root_valid?(roots_to_validate)
154 def each_root_valid?(roots_to_validate)
155 left = right = 0
155 left = right = 0
156 roots_to_validate.all? do |root|
156 roots_to_validate.all? do |root|
157 returning(root.left > left && root.right > right) do
157 (root.left > left && root.right > right).tap do
158 left = root.left
158 left = root.left
159 right = root.right
159 right = root.right
160 end
160 end
@@ -76,7 +76,7 class PluginMigrationGenerator < Rails::Generator::Base
76 # plugin names involved is shorter than 230 characters that one will be
76 # plugin names involved is shorter than 230 characters that one will be
77 # used. Otherwise a shorter name will be returned.
77 # used. Otherwise a shorter name will be returned.
78 def build_migration_name
78 def build_migration_name
79 returning descriptive_migration_name do |name|
79 descriptive_migration_name.tap do |name|
80 name.replace short_migration_name if name.length > MAX_FILENAME_LENGTH
80 name.replace short_migration_name if name.length > MAX_FILENAME_LENGTH
81 end
81 end
82 end
82 end
@@ -71,7 +71,7 module GravatarHelper
71 email_hash = Digest::MD5.hexdigest(email)
71 email_hash = Digest::MD5.hexdigest(email)
72 options = DEFAULT_OPTIONS.merge(options)
72 options = DEFAULT_OPTIONS.merge(options)
73 options[:default] = CGI::escape(options[:default]) unless options[:default].nil?
73 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|
75 opts = []
75 opts = []
76 [:rating, :size, :default].each do |opt|
76 [:rating, :size, :default].each do |opt|
77 unless options[opt].nil?
77 unless options[opt].nil?
General Comments 0
You need to be logged in to leave comments. Login now