Sha256: 59274e19f3e25cbb632749adcfad893a1a96c0b5afc29a474c3b83bab0de44e6

Contents?: true

Size: 494 Bytes

Versions: 1

Compression:

Stored size: 494 Bytes

Contents

# frozen_string_literal: true
module Mongoload
  module ContextWithAutoInclude
    def documents_for_iteration
      results = super
      if results.is_a?(Mongo::Collection::View)
        results = results.map { |doc| Mongoid::Factory.from_db(klass, doc, criteria.options[:fields]) }
      end
      results.tap do |documents|
        Mongoload::AutoIncludeContext.register_docs(documents.to_a)
      end
    end
  end
end

Mongoid::Contextual::Mongo.prepend Mongoload::ContextWithAutoInclude

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mongoload-0.0.3 lib/mongoload/patches/contextual_mongo.rb