#primary_key ⇒ nil
The primary key
# File 'lib/mongoid/association/embedded/embeds_many.rb', line 85
def primary_key; end
123456789_123456789_123456789_123456789_123456789_
Relationships & Source Files | |
Namespace Children | |
Modules:
| |
Classes:
| |
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
|
|
Inherits: | Object |
Defined in: | lib/mongoid/association/embedded/embeds_many.rb, lib/mongoid/association/embedded/embeds_many/binding.rb, lib/mongoid/association/embedded/embeds_many/buildable.rb, lib/mongoid/association/embedded/embeds_many/proxy.rb |
The EmbedsMany type association.
The options available for this type of association, in addition to the common ones.
[ :as, :cascade_callbacks, :cyclic, :order, :store_as, :before_add, :after_add, :before_remove, :after_remove ]
The complete list of valid options for this association, including the shared ones.
(ASSOCIATION_OPTIONS + SHARED_OPTIONS).freeze
::Mongoid::Association::Relatable
- IncludedIs this association type embedded?
Is this association polymorphic?
Does this association type store the foreign key?
::Mongoid::Threaded::Lifecycle
- Included#_assigning | Begin the assignment of attributes. |
#_assigning? | Is the current thread in assigning mode? |
#_binding | Execute a block in binding mode. |
#_binding? | Is the current thread in binding mode? |
#_building | Execute a block in building mode. |
#_building? | Is the current thread in building mode? |
#_creating? | Is the current thread in creating mode? |
#_loading | Execute a block in loading mode. |
#_loading? | Is the current thread in loading mode? |
::Mongoid::Association::Relatable
- Included#destructive? | Whether the dependent method is destructive. |
#in_to? | Is this association an embedded_in or belongs_to association? |
#many? | Is this association an embeds_many or has_many association? |
#name | The name of the association. |
#one? | Is this association an embeds_one or has_one association? |
#options | The options on this association. |
#parent_inclusions | The associations above this one in the inclusion tree. |
#parent_inclusions= | The associations above this one in the inclusion tree. |
#validate? | Whether the associated object(s) should be validated. |
::Mongoid::Association::Options
- Included#autobuilding? | Whether the association is autobuilding. |
#autosave |
|
#autosave? | Alias for Options#autosave. |
#cascading_callbacks? | Whether the association has callbacks cascaded down from the parent. |
#counter_cached? | Whether the association is counter-cached. |
#cyclic? | Is the association cyclic. |
#forced_nil_inverse? | Whether the association has forced nil inverse (So no foreign keys are saved). |
#indexed? | Whether to index the primary or foreign key field. |
#polymorphic? | Whether this association is polymorphic. |
#touchable? | Whether the association object should be automatically touched when its inverse object is updated. |
Get a criteria object for searching given a parent and children documents.
The key that is used to get the attributes for the associated object.
The nested builder object.
Get the path calculator for the supplied document.
The primary key.
Get the association proxy class for this association type.
Setup the instance methods, fields, etc.
The field key used to store the list of association objects.
The field used to store the type of the related object.
Get the default validation setting for the association.
Buildable
- Included#build | Builds the document out of the attributes using the provided association metadata. |
::Mongoid::Association::Relatable
- Included#== | Compare this association to another. |
#bindable? | Whether trying to bind an object using this association should raise an error. |
#class_name | Alias for Relatable#relation_class_name. |
#counter_cache_column_name | Get the counter cache column name. |
#create_relation | Create an association proxy object using the owner and target. |
#extension | Get the extension. |
#foreign_key_check | Get the name of the method to check if the foreign key has changed. |
#foreign_key_setter | The name of the foreign key setter method. |
#get_callbacks | Get the callbacks for a given type. |
#initialize | Initialize the |
#inverse | Get the inverse name. |
#inverse_association | Get the inverse’s association metadata. |
#inverse_class | The class of the object owning this association. |
#inverse_class_name | The class name of the object owning this association. |
#inverse_klass | Alias for Relatable#inverse_class. |
#inverse_setter | The name of the inverse setter method. |
#inverse_type | Get the inverse type. |
#inverse_type_setter | Gets the setter for the field that sets the type of document on a polymorphic association. |
#inverses | Get the inverse names. |
#key | The foreign key field if this association stores a foreign key. |
#klass | Alias for Relatable#relation_class. |
#path | The atomic path for this association. |
#relation_class | The class of the association object(s). |
#relation_class_name |
|
#setter | The name of the setter on this object for assigning an associated object. |
#type_setter | Get the type setter. |
#create_extension!, #default_inverse, #define_autosaver!, #define_builder!, #define_counter_cache_callbacks!, #define_creator!, #define_dependency!, #define_existence_check!, #define_getter!, #define_ids_getter!, #define_ids_setter!, #define_setter!, #define_touchable!, | |
#inverse_association_classes | Gets the model classes with inverse associations of this model. |
#namespace_hierarchy | Returns an array of classes/modules forming the namespace hierarchy where symbols referenced in the provided class/module would be looked up by Ruby. |
#polymorph!, | |
#resolve_name | Resolves the given class/module name in the context of the specified module, as Ruby would when a constant is referenced in the source. |
#setup_index!, #validate! |
::Mongoid::Association::Options
- Included#as | Returns the name of the parent to a polymorphic child. |
#dependent | Specify what happens to the associated object when the owner is destroyed. |
#inverse_of | The name the owning object uses to refer to this association. |
#order | The custom sorting options on the association. |
#primary_key |
|
#store_as | The store_as option. |
#touch_field | The field for saving the associated object’s type. |
#type | The field for saving the associated object’s type. |
::Mongoid::Association::Constrainable
- Included#convert_to_foreign_key | Convert the supplied object to the appropriate type to set as the foreign key for an association. |
#convert_polymorphic |
true
(readonly)
Is this association type embedded?
# File 'lib/mongoid/association/embedded/embeds_many.rb', line 66
def ; true; end
true
| false
(readonly)
Is this association polymorphic?
# File 'lib/mongoid/association/embedded/embeds_many.rb', line 97
def polymorphic? @polymorphic ||= !!@options[:as] end
false
(readonly)
Does this association type store the foreign key?
# File 'lib/mongoid/association/embedded/embeds_many.rb', line 80
def stores_foreign_key?; false; end
Get a criteria object for searching given a parent and children documents.
# File 'lib/mongoid/association/embedded/embeds_many.rb', line 137
def criteria(base, target) criterion = klass.scoped criterion. = true criterion.documents = target criterion.parent_document = base criterion.association = self apply_ordering(criterion) end
# File 'lib/mongoid/association/embedded/embeds_many.rb', line 170
def determine_inverses(other) matches = relation_class.relations.values.select do |rel| relation_complements.include?(rel.class) && # https://jira.mongodb.org/browse/MONGOID-4882 rel.relation_class_name.sub(/\A::/, '') == inverse_class_name end if matches.size > 1 raise Errors::AmbiguousRelationship.new(relation_class, @owner_class, name, matches) end matches.collect { |m| m.name } unless matches.blank? end
The key that is used to get the attributes for the associated object.
# File 'lib/mongoid/association/embedded/embeds_many.rb', line 59
def key store_as.to_s end
The nested builder object.
Get the path calculator for the supplied document.
# File 'lib/mongoid/association/embedded/embeds_many.rb', line 166
def polymorphic_inverses(other = nil) [ as ] end
nil
The primary key
# File 'lib/mongoid/association/embedded/embeds_many.rb', line 85
def primary_key; end
Get the association proxy class for this association type.
# File 'lib/mongoid/association/embedded/embeds_many.rb', line 90
def relation Proxy end
# File 'lib/mongoid/association/embedded/embeds_many.rb', line 162
def relation_complements @relation_complements ||= [ Embedded::EmbeddedIn ].freeze end
self
Setup the instance methods, fields, etc. on the association owning class.
# File 'lib/mongoid/association/embedded/embeds_many.rb', line 42
def setup! setup_instance_methods! @owner_class. = @owner_class. .merge(name => self) @owner_class.aliased_fields[name.to_s] = store_as if store_as self end
The field key used to store the list of association objects.
# File 'lib/mongoid/association/embedded/embeds_many.rb', line 52
def store_as @store_as ||= (@options[:store_as].try(:to_s) || name.to_s) end
nil
Only relevant if the association is polymorphic.
The field used to store the type of the related object.
# File 'lib/mongoid/association/embedded/embeds_many.rb', line 106
def type @type ||= "#{as}_type" if polymorphic? end
true
Get the default validation setting for the association. Determines if by default a validates associated will occur.
# File 'lib/mongoid/association/embedded/embeds_many.rb', line 75
def validation_default; true; end