Module: Mongoid::Criteria::Marshalable
- Included in:
- Mongoid::Criteria
- Defined in:
- lib/mongoid/criteria/marshalable.rb
Overview
Mixin module for Mongoid::Criteria which adds custom Marshal.dump functionality.
Instance Method Summary collapse
-
#marshal_dump ⇒ Array<Object>
Provides the data needed to Marshal.dump a criteria.
-
#marshal_load(data) ⇒ Object
Resets the criteria object after a Marshal.load.
Instance Method Details
#marshal_dump ⇒ Array<Object>
Provides the data needed to Marshal.dump a criteria.
Note :mongo is written here for backwards compatibility with Mongoid 7 and earlier.
20 21 22 23 |
# File 'lib/mongoid/criteria/marshalable.rb', line 20 def marshal_dump data = [ klass, :mongo, inclusions, documents, strategy, negating ] data.push().push(dump_hash(:selector)).push(dump_hash(:options)) end |
#marshal_load(data) ⇒ Object
Resets the criteria object after a Marshal.load
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/mongoid/criteria/marshalable.rb', line 31 def marshal_load(data) @scoping_options, raw_selector, = data.pop(3) @klass, driver, @inclusions, @documents, @strategy, @negating = data if driver == :mongo1x raise NotImplementedError, "Mongoid no longer supports marshalling with driver version 1.x." end @selector = load_hash(Queryable::Selector, raw_selector) @options = load_hash(Queryable::Options, ) end |