Skip to content

Commit

Permalink
Slight change in Query method missing stuff. Feel like this is easier…
Browse files Browse the repository at this point in the history
… to read than the nested ifs.
  • Loading branch information
jnunemaker committed Jun 15, 2010
1 parent 2592af1 commit 2df3ebd
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions lib/mongo_mapper/plugins/querying/decorator.rb
Expand Up @@ -30,19 +30,13 @@ def first(opts={})
def last(opts={})
model.load(super)
end

private
def method_missing(method, *args, &block)
if model.respond_to?(method)
query = model.send(method, *args, &block)
if query.is_a?(Plucky::Query)
merge(query)
else
super
end
else
super
end
return super unless model.respond_to?(method)
result = model.send(method, *args, &block)
return super unless result.is_a?(Plucky::Query)
merge(result)
end
end
end
Expand Down

0 comments on commit 2df3ebd

Please sign in to comment.