Class: Mongoid::Contextual::Mongo

Inherits:
Object
  • Object
show all
Defined in:
lib/rocket_job/extensions/mongoid/contextual/mongo.rb

Instance Method Summary collapse

Constructor Details

#initialize(criteria) ⇒ Mongo

Returns a new instance of Mongo.



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/rocket_job/extensions/mongoid/contextual/mongo.rb', line 5

def initialize(criteria)
  @criteria = criteria
  @klass    = criteria.klass
  @cache    = criteria.options[:cache]
  # Only line changed is here, get collection name from criteria, not @klass
  # @collection = @klass.collection
  @collection = criteria.collection

  criteria.send(:merge_type_selection)
  @view = collection.find(criteria.selector, session: _session)
  apply_options
end