]> source.dussan.org Git - redmine.git/commitdiff
add builtin named_scope
authorNicolas Chuche <nicolas.chuche@barna.be>
Mon, 8 Sep 2008 13:09:54 +0000 (13:09 +0000)
committerNicolas Chuche <nicolas.chuche@barna.be>
Mon, 8 Sep 2008 13:09:54 +0000 (13:09 +0000)
git-svn-id: http://redmine.rubyforge.org/svn/branches/nbc@1792 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/role.rb

index 6d2f643fdfdf20cc71020a7ae696eb5d4088f3b2..5ff9470f91f2348f71f8f2b72b78905a7ec6e400 100644 (file)
@@ -19,6 +19,11 @@ class Role < ActiveRecord::Base
   # Built-in roles
   BUILTIN_NON_MEMBER = 1
   BUILTIN_ANONYMOUS  = 2
+
+  named_scope :builtin, lambda { |*args|
+    compare = 'not' if args.first == true
+    { :conditions => "#{compare} builtin = 0" }
+  }
   
   before_destroy :check_deletable
   has_many :workflows, :dependent => :delete_all do