Module | Mongoid::Attributes::Processing |
In: |
lib/mongoid/attributes/processing.rb
|
This module contains the behavior for processing attributes.
Process the provided attributes casting them to their proper values if a field exists for them on the document. This will be limited to only the attributes provided in the suppied Hash so that no extra nil values get put into the document‘s attributes.
@example Process the attributes.
person.process(:title => "sir", :age => 40)
@param [ Hash ] attrs The attributes to set. @param [ Symbol ] role A role for scoped mass assignment. @param [ Boolean ] guard_protected_attributes False to skip mass assignment protection.
@since 2.0.0.rc.7
If the key provided is the name of a relation or a nested attribute, we need to wait until all other attributes are set before processing these.
@example Is the attribute pending?
document.pending_attribute?(:name, "Durran")
@param [ Symbol ] key The name of the attribute. @param [ Object ] value The value of the attribute.
@return [ true, false ] True if pending, false if not.
@since 2.0.0.rc.7
Get all the pending nested attributes that need to be set.
@example Get the pending nested attributes.
document.pending_nested
@return [ Hash ] The pending nested attributes in key/value pairs.
@since 2.0.0.rc.7
Get all the pending relations that need to be set.
@example Get the pending relations.
document.pending_relations
@return [ Hash ] The pending relations in key/value pairs.
@since 2.0.0.rc.7
If the attribute is dynamic, add a field for it with a type of object and then either way set the value.
@example Process the attribute.
document.process_attribute(name, value)
@param [ Symbol ] name The name of the field. @param [ Object ] value The value of the field.
@since 2.0.0.rc.7
Process all the pending nested attributes that needed to wait until ids were set to fire off.
@example Process the nested attributes.
document.process_nested
@since 2.0.0.rc.7
Process all the pending items, then clear them out.
@example Process the pending items.
document.process_pending
@since 2.0.0.rc.7