Class: Mongoid::Fields::Internal::Array
- Includes:
- Serializable
- Defined in:
- lib/mongoid/fields/internal/array.rb
Overview
Defines the behaviour for array fields.
Instance Attribute Summary
Attributes included from Serializable
#default_val, #label, #localize, #name, #options
Instance Method Summary collapse
-
#add_atomic_changes(document, key, mods, new, old) ⇒ Object
Adds the atomic changes for this type of resizable field.
-
#resizable? ⇒ true
Array fields are resizable.
-
#serialize(object) ⇒ Array
Serialize the object from the type defined in the model to a MongoDB compatible object to store.
Methods included from Serializable
#constraint, #deserialize, #eval_default, #foreign_key?, #localized?, #metadata, #object_id_field?, #selection, #type, #versioned?
Instance Method Details
#add_atomic_changes(document, key, mods, new, old) ⇒ Object
Adds the atomic changes for this type of resizable field.
22 23 24 25 26 27 28 29 30 |
# File 'lib/mongoid/fields/internal/array.rb', line 22 def add_atomic_changes(document, key, mods, new, old) if new.any? && old.any? mods[key] = document.attributes[key] elsif new.any? document.atomic_array_pushes[key] = new elsif old.any? document.atomic_array_pulls[key] = old end end |
#resizable? ⇒ true
Array fields are resizable.
40 |
# File 'lib/mongoid/fields/internal/array.rb', line 40 def resizable?; true; end |
#serialize(object) ⇒ Array
Serialize the object from the type defined in the model to a MongoDB compatible object to store.
53 54 55 |
# File 'lib/mongoid/fields/internal/array.rb', line 53 def serialize(object) raise_or_return(object) end |