Permalink
Browse files

Tweak alias_scope documentation, add a spec for coverage, and allow a…

…liasing scopes by symbol that have arguments.
  • Loading branch information...
1 parent 613a527 commit 0967c91673a39bbd0b79ea61d7e6fd171625e7c8 @johndouthat committed Mar 23, 2012
@@ -8,7 +8,7 @@ module AliasScope
# or represents a named scope procedure. Ex:
#
# class User
- # def teenager
+ # def self.teenager
# age_gte(13).age_lte(19)
# end
# end
@@ -37,7 +37,7 @@ def alias_scope(name, options = nil)
define_method name do |*args|
case options
when Symbol
- send(options)
+ send(options, *args)
else
options.call(*args)
end
@@ -11,6 +11,13 @@
User.username_has("bjohnson").all.should == User.find_all_by_username("bjohnson")
end
+ it "should allow alias scopes with symbols" do
+ User.alias_scope :login_has, :username_has
+ User.create(:username => "bjohnson")
+ User.create(:username => "thunt")
+ User.login_has("bjohnson").all.should == User.find_all_by_username("bjohnson")
+ end
+
it "should allow alias scopes from the search object" do
search = User.search
search.username_has = "bjohnson"

0 comments on commit 0967c91

Please sign in to comment.