Class: Mongoid::Relations::NestedBuilder
- Defined in:
- lib/mongoid/relations/nested_builder.rb
Overview
This is the superclass for builders that are in charge of handling creation, deletion, and updates of documents through that ever so lovely #accepts_nested_attributes_for.
Direct Known Subclasses
Builders::NestedAttributes::Many, Builders::NestedAttributes::One
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#existing ⇒ Object
Returns the value of attribute existing.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
-
#allow_destroy? ⇒ true, false
Determines if destroys are allowed for this document.
-
#convert_id(id) ⇒ BSON::ObjectId, ...
Convert an id to its appropriate type.
-
#reject?(attrs) ⇒ true, false
Returns the reject if option defined with the macro.
-
#update_only? ⇒ true, false
Determines if only updates can occur.
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
9 10 11 |
# File 'lib/mongoid/relations/nested_builder.rb', line 9 def attributes @attributes end |
#existing ⇒ Object
Returns the value of attribute existing.
9 10 11 |
# File 'lib/mongoid/relations/nested_builder.rb', line 9 def existing @existing end |
#metadata ⇒ Object
Returns the value of attribute metadata.
9 10 11 |
# File 'lib/mongoid/relations/nested_builder.rb', line 9 def @metadata end |
#options ⇒ Object
Returns the value of attribute options.
9 10 11 |
# File 'lib/mongoid/relations/nested_builder.rb', line 9 def @options end |
Instance Method Details
#allow_destroy? ⇒ true, false
Determines if destroys are allowed for this document.
19 20 21 |
# File 'lib/mongoid/relations/nested_builder.rb', line 19 def allow_destroy? [:allow_destroy] || false end |
#convert_id(id) ⇒ BSON::ObjectId, ...
Durran: Move this into a common reusable place.
Convert an id to its appropriate type.
63 64 65 |
# File 'lib/mongoid/relations/nested_builder.rb', line 63 def convert_id(id) .constraint.convert(id) end |
#reject?(attrs) ⇒ true, false
Returns the reject if option defined with the macro.
33 34 35 36 |
# File 'lib/mongoid/relations/nested_builder.rb', line 33 def reject?(attrs) criteria = [:reject_if] criteria ? criteria.call(attrs) : false end |
#update_only? ⇒ true, false
Determines if only updates can occur. Only valid for one-to-one relations.
47 48 49 |
# File 'lib/mongoid/relations/nested_builder.rb', line 47 def update_only? [:update_only] || false end |