Module: Mongoid::Criteria::Marshalable
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Included In:
| |
Defined in: | lib/mongoid/criteria/marshalable.rb |
Overview
Mixin module for ::Mongoid::Criteria
which adds custom Marshal.dump functionality.
Instance Method Summary
-
#marshal_dump ⇒ Array<Object>
Provides the data needed to Marshal.dump a criteria.
-
#marshal_load(data)
Resets the criteria object after a Marshal.load.
- #dump_hash(name) private
- #load_hash(hash_class, raw) private
Instance Method Details
#dump_hash(name) (private)
[ GitHub ]# File 'lib/mongoid/criteria/marshalable.rb', line 45
def dump_hash(name) send(name).inject({}) do |raw, (key, value)| raw[key] = value raw end end
#load_hash(hash_class, raw) (private)
[ GitHub ]
#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.
#marshal_load(data)
Resets the criteria object after a Marshal.load
# 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