Sha256: 5fdb862a9c336122ad3965b59d0311233875d698f2fac933a0ae50b932c3add3

Contents?: true

Size: 384 Bytes

Versions: 6

Compression:

Stored size: 384 Bytes

Contents

Mongoid::Criteria.class_eval do
  include Mongoid::Criterion::EagerLoading

  alias_method :origin_each, :each

  def each(&block)
    if @eager_loadings
      # if eager loadings are used, preload the associations.
      docs = []
      context.iterate { |doc| docs << doc }
      preload(docs)
      docs.each(&block)
      self
    else
      origin_each(&block)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mongoid-eager-loading-0.3.1 lib/mongoid-eager-loading/mongoid/criteria.rb
mongoid-eager-loading-0.3.0 lib/mongoid-eager-loading/mongoid/criteria.rb
mongoid-eager-loading-0.2.0 lib/mongoid-eager-loading/mongoid/criteria.rb
mongoid-eager-loading-0.1.2 lib/mongoid-eager-loading/mongoid/criteria.rb
mongoid-eager-loading-0.1.1 lib/mongoid-eager-loading/mongoid/criteria.rb
mongoid-eager-loading-0.1.0 lib/mongoid-eager-loading/mongoid/criteria.rb