1
0
mirror of https://github.com/meineerde/redmine.git synced 2025-12-29 11:49:37 +00:00

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
This commit is contained in:
Toshi MARUYAMA 2020-08-09 15:57:53 +00:00
parent cdb4743408
commit de3fcfe63e

View File

@ -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