Permalink
Browse files

Use Plucky::Methods to determine what methods to delegate to query [F…

…ixes #266]
  • Loading branch information...
1 parent 2f746fb commit b965105ea203368234636df21c64f05358a467fb @brianhempel brianhempel committed Apr 26, 2012
@@ -4,7 +4,8 @@ module Plugins
module Associations
class ManyDocumentsProxy < Collection
include DynamicQuerying::ClassMethods
- include Querying::PluckyMethods
+
+ def_delegators :query, *(Querying::Methods - [:to_a, :size, :empty?])
def replace(docs)
load_target
@@ -1,6 +1,5 @@
# encoding: UTF-8
require 'mongo_mapper/plugins/querying/decorator'
-require 'mongo_mapper/plugins/querying/plucky_methods'
module MongoMapper
module Plugins
@@ -9,13 +8,8 @@ module Querying
module ClassMethods
extend Forwardable
- include PluckyMethods
- def_delegators :query, :to_a, :size, :empty?
-
- def find_each(opts={})
- super(opts).each { |doc| yield(doc) }
- end
+ def_delegators :query, *Querying::Methods
def find_by_id(id)
find_one(:_id => id)
@@ -2,6 +2,8 @@
module MongoMapper
module Plugins
module Querying
+ Methods = Plucky::Methods + [:find!]
+
module Decorator
include DynamicQuerying::ClassMethods
@@ -1,21 +0,0 @@
-# encoding: UTF-8
-require 'forwardable'
-
-module MongoMapper
- module Plugins
- module Querying
- module PluckyMethods
- extend Forwardable
- def_delegators :query, :where, :filter,
- :fields, :ignore, :only,
- :limit, :paginate, :per_page, :skip, :offset,
- :sort, :order, :reverse,
- :count,
- :distinct,
- :last, :first, :find_one, :all, :find_each,
- :find, :find!,
- :exists?, :exist?
- end
- end
- end
-end

0 comments on commit b965105

Please sign in to comment.