Permalink
Browse files

Clean up how the SearchProxy calls scopes with no arity

  • Loading branch information...
1 parent ef1e32a commit 85fdcc60a794947a2c5b31ca5321c2ed3e16938a @binarylogic committed Jun 12, 2009
Showing with 7 additions and 3 deletions.
  1. +1 −1 README.rdoc
  2. +6 −2 lib/searchlogic/search_proxy.rb
View
@@ -75,7 +75,7 @@ Again these are just named scopes. You can chain them together, call methods off
Benchmark.bm do |x|
x.report { 10.times { Event.tickets_id_gt(10).all(:include => :tickets) } }
- x.report { 10.times { Event.tickets_id_gt(20).all } }
+ x.report { 10.times { Event.tickets_id_gt(10).all } }
end
user system total real
10.120000 0.170000 10.290000 ( 12.625521)
@@ -45,8 +45,12 @@ def method_missing(name, *args, &block)
klass.send(scope_name, value) if !klass.respond_to?(scope_name)
arity = klass.named_scope_arity(scope_name)
- if (!arity || arity == 0) && value != true
- scope
+ if !arity || arity == 0
+ if value == true
+ scope.send(scope_name)
+ else
+ scope
+ end
else
scope.send(scope_name, value)
end

0 comments on commit 85fdcc6

Please sign in to comment.