Class: Mongoid::Fields::Serializable::NilClass

Inherits:
Object
  • Object
show all
Includes:
Mongoid::Fields::Serializable
Defined in:
lib/mongoid/fields/serializable/nil_class.rb

Overview

Defines the behaviour for nil fields.

Instance Attribute Summary

Attributes included from Mongoid::Fields::Serializable

#default, #label, #name, #options

Instance Method Summary collapse

Methods included from Mongoid::Fields::Serializable

#cast_on_read?, #constraint, #eval_default, #metadata, #object_id_field?, #type, #versioned?

Instance Method Details

#deserialize(object) ⇒ nil

Deserialize this field from the type stored in MongoDB to the type defined on the model

Examples:

Deserialize the field.

field.deserialize(object)

Parameters:

  • object (Object)

    The object to cast.

Returns:

  • (nil)

    Always nil.

Since:

  • 2.1.0



21
# File 'lib/mongoid/fields/serializable/nil_class.rb', line 21

def deserialize(object); nil; end

#serialize(object) ⇒ nil

Serialize the object from the type defined in the model to a MongoDB compatible object to store.

Examples:

Serialize the field.

field.serialize(object)

Parameters:

  • object (Object)

    The object to cast.

Returns:

  • (nil)

    always nil.

Since:

  • 2.1.0



34
# File 'lib/mongoid/fields/serializable/nil_class.rb', line 34

def serialize(object); nil; end