Module: Mongoid::Association::Embedded::Cyclic::ClassMethods
| Relationships & Source Files | |
| Extension / Inclusion / Inheritance Descendants | |
|
Extended In:
| |
| Defined in: | lib/mongoid/association/embedded/cyclic.rb |
Instance Method Summary
-
#recursively_embeds_many(options = {})
Create a cyclic embedded association that creates a tree hierarchy for the document and many embedded child documents.
-
#recursively_embeds_one(options = {})
Create a cyclic embedded association that creates a single self referencing relationship for a parent and a single child.
-
#cyclic_child_name(many = true) ⇒ String
private
Determines the child name given the class.
-
#cyclic_parent_name ⇒ String
private
Determines the parent name given the class.
Instance Method Details
#cyclic_child_name(many = true) ⇒ String (private)
Determines the child name given the class.
# File 'lib/mongoid/association/embedded/cyclic.rb', line 93
def cyclic_child_name(many = true) :"child_#{name.demodulize.underscore.send(many ? :pluralize : :singularize)}" end
#cyclic_parent_name ⇒ String (private)
Determines the parent name given the class.
# File 'lib/mongoid/association/embedded/cyclic.rb', line 80
def cyclic_parent_name :"parent_#{name.demodulize.underscore.singularize}" end
#recursively_embeds_many(options = {})
Create a cyclic embedded association that creates a tree hierarchy for the document and many embedded child documents.
This provides the default nomenclature for accessing a parent document or its children.
# File 'lib/mongoid/association/embedded/cyclic.rb', line 36
def ( = {}) ( cyclic_child_name, .merge(class_name: name, cyclic: true) ) cyclic_parent_name, class_name: name, cyclic: true end
#recursively_embeds_one(options = {})
Create a cyclic embedded association that creates a single self referencing relationship for a parent and a single child.
This provides the default nomenclature for accessing a parent document or its children.
# File 'lib/mongoid/association/embedded/cyclic.rb', line 64
def ( = {}) ( cyclic_child_name(false), .merge(class_name: name, cyclic: true) ) cyclic_parent_name, class_name: name, cyclic: true end