123456789_123456789_123456789_123456789_123456789_

Module: Mongoid::Association::Marshalable

Overview

Mixin module for Mongoid::Association::Proxy which adds custom Marshal.dump functionality.

Instance Method Summary

Instance Method Details

#marshal_dumpArray<Object>

Provides the data needed to Marshal.dump an association proxy.

Examples:

Dump the proxy.

Marshal.dump(proxy)

Returns:

  • (Array<Object>)

    The dumped data.

[ GitHub ]

  
# File 'lib/mongoid/association/marshalable.rb', line 17

def marshal_dump
  [ _base, _target, _association ]
end

#marshal_load(data) ⇒ Array<Object>

Takes the provided data and sets it back on the proxy.

Examples:

Load the proxy.

Marshal.load(proxy)

Parameters:

  • data (Array<Object>)

    The data to set on the proxy.

Returns:

  • (Array<Object>)

    The loaded data.

[ GitHub ]

  
# File 'lib/mongoid/association/marshalable.rb', line 29

def marshal_load(data)
  @_base, @_target, @_association = data
  extend_proxy(_association.extension) if _association.extension
end