Module: Mongoid::Association::Nested::Buildable
- Defined in:
- build/mongoid-8.1/lib/mongoid/association/nested/nested_buildable.rb
Instance Attribute Summary collapse
-
#association ⇒ Object
Returns the value of attribute association.
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#existing ⇒ Object
Returns the value of attribute existing.
-
#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(klass, id) ⇒ BSON::ObjectId | String | Object
Convert an id to its appropriate type.
-
#reject?(document, 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
#association ⇒ Object
Returns the value of attribute association.
8 9 10 |
# File 'build/mongoid-8.1/lib/mongoid/association/nested/nested_buildable.rb', line 8 def association @association end |
#attributes ⇒ Object
Returns the value of attribute attributes.
8 9 10 |
# File 'build/mongoid-8.1/lib/mongoid/association/nested/nested_buildable.rb', line 8 def attributes @attributes end |
#existing ⇒ Object
Returns the value of attribute existing.
8 9 10 |
# File 'build/mongoid-8.1/lib/mongoid/association/nested/nested_buildable.rb', line 8 def existing @existing end |
#options ⇒ Object
Returns the value of attribute options.
8 9 10 |
# File 'build/mongoid-8.1/lib/mongoid/association/nested/nested_buildable.rb', line 8 def @options end |
Instance Method Details
#allow_destroy? ⇒ true | false
Determines if destroys are allowed for this document.
16 17 18 |
# File 'build/mongoid-8.1/lib/mongoid/association/nested/nested_buildable.rb', line 16 def allow_destroy? [:allow_destroy] || false end |
#convert_id(klass, id) ⇒ BSON::ObjectId | String | Object
Convert an id to its appropriate type.
60 61 62 |
# File 'build/mongoid-8.1/lib/mongoid/association/nested/nested_buildable.rb', line 60 def convert_id(klass, id) klass.using_object_ids? ? BSON::ObjectId.mongoize(id) : id end |
#reject?(document, attrs) ⇒ true | false
Returns the reject if option defined with the macro.
29 30 31 32 33 34 35 36 37 38 |
# File 'build/mongoid-8.1/lib/mongoid/association/nested/nested_buildable.rb', line 29 def reject?(document, attrs) case callback = [:reject_if] when Symbol document.method(callback).arity == 0 ? document.send(callback) : document.send(callback, attrs) when Proc callback.call(attrs) else false end end |
#update_only? ⇒ true | false
Determines if only updates can occur. Only valid for one-to-one associations.
47 48 49 |
# File 'build/mongoid-8.1/lib/mongoid/association/nested/nested_buildable.rb', line 47 def update_only? [:update_only] || false end |