class Mongoid::Relations::NestedBuilder
#accepts_nested_attributes_for.
creation, deletion, and updates of documents through that ever so lovely
This is the superclass for builders that are in charge of handling
def allow_destroy?
- Since: - 2.0.0.rc.1
Returns:
-
(true, false)- True if the allow destroy option was set.
Other tags:
- Example: Do we allow a destroy? -
def allow_destroy? options[:allow_destroy] || false end
def convert_id(klass, id)
- Since: - 2.0.0.rc.6
Returns:
-
(BSON::ObjectId, String, Object)- The converted id.
Parameters:
-
id(String) -- The id, usually coming from the form. -
klass(Class) -- The class we're trying to convert for.
Other tags:
- Example: Convert the id. -
def convert_id(klass, id) klass.using_object_ids? ? BSON::ObjectId.mongoize(id) : id end
def reject?(document, attrs)
- Since: - 2.0.0.rc.1
Returns:
-
(true, false)- True and call proc or method if rejectable, false if not.
Parameters:
-
attrs(Hash) -- The attributes to check for rejection. -
The() -- parent document of the relation
Other tags:
- Example: Is there a reject proc? -
def reject?(document, attrs) case callback = options[: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
def update_only?
- Since: - 2.0.0.rc.1
Returns:
-
(true, false)- True if the update_only option was set.
Other tags:
- Example: Is this update only? -
def update_only? options[:update_only] || false end