Module: Mongoid::Criteria::Marshalable

Included in:
Mongoid::Criteria
Defined in:
build/mongoid-7.4/lib/mongoid/criteria/marshalable.rb

Instance Method Summary collapse

Instance Method Details

#marshal_dumpArray<Object>

Provides the data needed to Marshal.dump a criteria.

Examples:

Dump the criteria.

Marshal.dump(criteria)

Returns:

  • (Array<Object>)

    The dumped data.



13
14
15
16
# File 'build/mongoid-7.4/lib/mongoid/criteria/marshalable.rb', line 13

def marshal_dump
  data = [ klass, driver, inclusions, documents, strategy, negating ]
  data.push(scoping_options).push(dump_hash(:selector)).push(dump_hash(:options))
end

#marshal_load(data) ⇒ Object

Resets the criteria object after a Marshal.load

Examples:

Load the criteria.

Marshal.load(criteria)

Parameters:

  • data (Array)

    The raw data.



24
25
26
27
28
29
# File 'build/mongoid-7.4/lib/mongoid/criteria/marshalable.rb', line 24

def marshal_load(data)
  @scoping_options, raw_selector, raw_options = data.pop(3)
  @klass, @driver, @inclusions, @documents, @strategy, @negating = data
  @selector = load_hash(Queryable::Selector, raw_selector)
  @options = load_hash(Queryable::Options, raw_options)
end