Class Mongoid::Relations::NestedBuilder
In: lib/mongoid/relations/nested_builder.rb
Parent: Object

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.

Methods

Attributes

attributes  [RW] 
existing  [RW] 
metadata  [RW] 
options  [RW] 

Public Instance methods

Determines if destroys are allowed for this document.

@example Do we allow a destroy?

  builder.allow_destroy?

@return [ true, false ] True if the allow destroy option was set.

@since 2.0.0.rc.1

Convert an id to its appropriate type.

@todo Durran: Move this into a common reusable place.

@example Convert the id.

  builder.convert_id("4d371b444835d98b8b000010")

@param [ String ] id The id, usually coming from the form.

@return [ BSON::ObjectId, String, Object ] The converted id.

@since 2.0.0.rc.6

Returns the reject if option defined with the macro.

@example Is there a reject proc?

  builder.reject?

@param The parent document of the relation @param [ Hash ] attrs The attributes to check for rejection.

@return [ true, false ] True and call proc or method if rejectable, false if not.

@since 2.0.0.rc.1

Determines if only updates can occur. Only valid for one-to-one relations.

@example Is this update only?

  builder.update_only?

@return [ true, false ] True if the update_only option was set.

@since 2.0.0.rc.1

[Validate]