aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/named_scope.rb
diff options
context:
space:
mode:
authorrick <rick@spacemonkey.local>2008-05-13 09:41:10 -0700
committerrick <rick@spacemonkey.local>2008-05-13 09:41:10 -0700
commit74fd17346f30fddba0e174ae17f5697f2c22279e (patch)
tree1267cea613ee4a73a2f5ddf3fb24d224dc8bbded /activerecord/lib/active_record/named_scope.rb
parentd09a8446d5606a5a0b5c024224b09a1318e9cf4d (diff)
parent4dedc7ddcaffa8c606af11ae2d32707131b99a2e (diff)
downloadrails-74fd17346f30fddba0e174ae17f5697f2c22279e.tar.gz
rails-74fd17346f30fddba0e174ae17f5697f2c22279e.tar.bz2
rails-74fd17346f30fddba0e174ae17f5697f2c22279e.zip
Merge branch 'master' of git@github.com:rails/rails
Diffstat (limited to 'activerecord/lib/active_record/named_scope.rb')
-rw-r--r--activerecord/lib/active_record/named_scope.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/named_scope.rb b/activerecord/lib/active_record/named_scope.rb
index 81b99f8e96..d43ebefc3b 100644
--- a/activerecord/lib/active_record/named_scope.rb
+++ b/activerecord/lib/active_record/named_scope.rb
@@ -71,6 +71,18 @@ module ActiveRecord
# end
# end
#
+ #
+ # For testing complex named scopes, you can examine the scoping options using the
+ # <tt>proxy_options</tt> method on the proxy itself.
+ #
+ # class Shirt < ActiveRecord::Base
+ # named_scope :colored, lambda { |color|
+ # { :conditions => { :color => color } }
+ # }
+ # end
+ #
+ # expected_options = { :conditions => { :colored => 'red' } }
+ # assert_equal expected_options, Shirt.colored('red').proxy_options
def named_scope(name, options = {}, &block)
scopes[name] = lambda do |parent_scope, *args|
Scope.new(parent_scope, case options