summaryrefslogtreecommitdiffstats
path: root/app/models/principal.rb
diff options
context:
space:
mode:
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>2020-11-10 11:10:24 +0000
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>2020-11-10 11:10:24 +0000
commit3e6622cd43abefbfaecb5ce54fbad74dd45ed114 (patch)
tree90bb086073987943197e4d66c26e814bfee01eb2 /app/models/principal.rb
parent31beca84b30eea72896007349a4213e743700f32 (diff)
downloadredmine-3e6622cd43abefbfaecb5ce54fbad74dd45ed114.tar.gz
redmine-3e6622cd43abefbfaecb5ce54fbad74dd45ed114.zip
use "do end" instead of {} at ActiveRecord scope lambda of app/models/principal.rb
git-svn-id: http://svn.redmine.org/redmine/trunk@20328 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/principal.rb')
-rw-r--r--app/models/principal.rb17
1 files changed, 8 insertions, 9 deletions
diff --git a/app/models/principal.rb b/app/models/principal.rb
index c31effec4..21962c6dc 100644
--- a/app/models/principal.rb
+++ b/app/models/principal.rb
@@ -41,7 +41,7 @@ class Principal < ActiveRecord::Base
# Groups and active users
scope :active, lambda { where(:status => STATUS_ACTIVE) }
- scope :visible, lambda {|*args|
+ scope :visible, (lambda do |*args|
user = args.first || User.current
if user.admin?
@@ -64,9 +64,9 @@ class Principal < ActiveRecord::Base
)
end
end
- }
+ end)
- scope :like, lambda {|q|
+ scope :like, (lambda do |q|
q = q.to_s
if q.blank?
where({})
@@ -85,13 +85,12 @@ class Principal < ActiveRecord::Base
end.join(' AND ')
sql << ')'
end
-
where(sql, params)
end
- }
+ end)
# Principals that are members of a collection of projects
- scope :member_of, lambda {|projects|
+ scope :member_of, (lambda do |projects|
projects = [projects] if projects.is_a?(Project)
if projects.blank?
where("1=0")
@@ -101,9 +100,9 @@ class Principal < ActiveRecord::Base
where(:status => [STATUS_LOCKED, STATUS_ACTIVE]).
where("#{Principal.table_name}.id IN (SELECT DISTINCT user_id FROM #{Member.table_name} WHERE project_id IN (?))", ids)
end
- }
+ end)
# Principals that are not members of projects
- scope :not_member_of, lambda {|projects|
+ scope :not_member_of, (lambda do |projects|
projects = [projects] unless projects.is_a?(Array)
if projects.empty?
where("1=0")
@@ -111,7 +110,7 @@ class Principal < ActiveRecord::Base
ids = projects.map(&:id)
where("#{Principal.table_name}.id NOT IN (SELECT DISTINCT user_id FROM #{Member.table_name} WHERE project_id IN (?))", ids)
end
- }
+ end)
scope :sorted, lambda { order(*Principal.fields_for_order_statement)}
# Principals that can be added as watchers