Sha256: 24ea64d11c241ae067051f2963729ea9ee0738375301e7780abbf4281b3ab30b

Contents?: true

Size: 726 Bytes

Versions: 12

Compression:

Stored size: 726 Bytes

Contents

require "mongoid/factory"

module RocketJob
  # Don't convert to Mongoid::Factory since it conflicts with Mongoid use.
  module MongoidFactory
    if Mongoid::VERSION.to_f >= 7.1
      def from_db(klass, attributes = nil, criteria = nil, selected_fields = nil)
        obj                 = super(klass, attributes, criteria, selected_fields)
        obj.collection_name = criteria.collection_name if criteria
        obj
      end
    else
      def from_db(klass, attributes = nil, criteria = nil)
        obj                 = super(klass, attributes, criteria)
        obj.collection_name = criteria.collection_name if criteria
        obj
      end
    end
  end
end

::Mongoid::Factory.extend(RocketJob::MongoidFactory)

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
rocketjob-5.4.1 lib/rocket_job/extensions/mongoid/factory.rb
rocketjob-5.4.0 lib/rocket_job/extensions/mongoid/factory.rb
rocketjob-5.4.0.beta2 lib/rocket_job/extensions/mongoid/factory.rb
rocketjob-5.4.0.beta1 lib/rocket_job/extensions/mongoid/factory.rb
rocketjob-5.3.3 lib/rocket_job/extensions/mongoid/factory.rb
rocketjob-5.3.2 lib/rocket_job/extensions/mongoid/factory.rb
rocketjob-5.3.1 lib/rocket_job/extensions/mongoid/factory.rb
rocketjob-5.3.0 lib/rocket_job/extensions/mongoid/factory.rb
rocketjob-5.2.0 lib/rocket_job/extensions/mongoid/factory.rb
rocketjob-5.2.0.beta3 lib/rocket_job/extensions/mongoid/factory.rb
rocketjob-5.2.0.beta2 lib/rocket_job/extensions/mongoid/factory.rb
rocketjob-5.2.0.beta1 lib/rocket_job/extensions/mongoid/factory.rb