summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>2020-08-09 15:57:53 +0000
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>2020-08-09 15:57:53 +0000
commitde3fcfe63eec2547693539ed279d65ac4fa149e8 (patch)
tree772981062d361d7bcd98ee23cdcd0ee897288365
parentcdb47434080c3d1c21a688be8db8517c85bd26e4 (diff)
downloadredmine-de3fcfe63eec2547693539ed279d65ac4fa149e8.tar.gz
redmine-de3fcfe63eec2547693539ed279d65ac4fa149e8.zip
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
-rw-r--r--app/models/user.rb15
1 files 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