Skip to content
Browse files

if scope method is found and called in model, then don't raise NoMeth…

…odError
  • Loading branch information...
1 parent 197c2f6 commit 3a78f04255d3ea01f4eac9a80f4a960e19b5baf7 @balexand balexand committed
Showing with 6 additions and 3 deletions.
  1. +5 −2 lib/mongo_mapper/plugins/querying/decorator.rb
  2. +1 −1 test/functional/test_scopes.rb
View
7 lib/mongo_mapper/plugins/querying/decorator.rb
@@ -27,8 +27,11 @@ def find!(*ids)
def method_missing(method, *args, &block)
return super unless model.respond_to?(method)
result = model.send(method, *args, &block)
- return super unless result.is_a?(Plucky::Query)
- merge(result)
+ if result.is_a?(Plucky::Query)
+ merge(result)
+ else
+ result
+ end
end
end
end
View
2 test/functional/test_scopes.rb
@@ -130,7 +130,7 @@ def self.young
should "not work if method does not return a query" do
@document.class_eval { def self.age; 20 end }
- lambda { @document.by_name('John').age }.should raise_error(NoMethodError)
+ @document.by_name('John').age.should == 20
end
end
end

0 comments on commit 3a78f04

Please sign in to comment.
Something went wrong with that request. Please try again.