module Mongoid::Serializable

def serialize_attribute(attrs, name, names, options)

Other tags:
    Since: - 3.0.0

Returns:
  • (Object) - The attribute.

Parameters:
  • options (Hash) -- The options.
  • names (Array) -- The names of all attributes.
  • name (String) -- The attribute name.
  • attrs (Hash) -- The attributes.

Other tags:
    Example: Serialize the attribute. -

Other tags:
    Api: - private
def serialize_attribute(attrs, name, names, options)
  if relations.key?(name)
    value = send(name)
    attrs[name] = value ? value.serializable_hash(options) : nil
  elsif names.include?(name) && !fields.key?(name)
    attrs[name] = read_raw_attribute(name)
  elsif !attribute_missing?(name)
    attrs[name] = send(name)
  end
end