From de3fcfe63eec2547693539ed279d65ac4fa149e8 Mon Sep 17 00:00:00 2001 From: Toshi MARUYAMA Date: Sun, 9 Aug 2020 15:57:53 +0000 Subject: use "do end" instead of {} at app/models/user.rb git-svn-id: http://svn.redmine.org/redmine/trunk@19973 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/user.rb | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index ce4fd547d..6c2adc141 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -583,9 +583,10 @@ class User < Principal def membership(project) project_id = project.is_a?(Project) ? project.id : project - @membership_by_project_id ||= Hash.new {|h, project_id| - h[project_id] = memberships.where(:project_id => project_id).first - } + @membership_by_project_id ||= + Hash.new do |h, project_id| + h[project_id] = memberships.where(:project_id => project_id).first + end @membership_by_project_id[project_id] end @@ -710,11 +711,11 @@ class User < Principal roles = roles_for_project(context) return false unless roles - roles.any? {|role| + roles.any? do |role| (context.is_public? || role.member?) && role.allowed_to?(action) && (block_given? ? yield(role, self) : true) - } + end elsif context && context.is_a?(Array) if context.empty? false @@ -730,10 +731,10 @@ class User < Principal # authorize if user has at least one role that has this permission roles = self.roles.to_a | [builtin_role] - roles.any? {|role| + roles.any? do |role| role.allowed_to?(action) && (block_given? ? yield(role, self) : true) - } + end else false end -- cgit v1.2.3