File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -1007,6 +1007,14 @@ setter methods for fields of your custom type.
1007
1007
venue = Venue.new(location: point) # This uses the Point#mongoize instance method.
1008
1008
venue = Venue.new(location: [ 12, 24 ]) # This uses the Point.mongoize class method.
1009
1009
1010
+ .. note::
1011
+
1012
+ The ``mongoize`` method should raise an "InvalidValue" error on values that
1013
+ are uncastable to your custom type. Mongoid will handle catching that error
1014
+ and writing ``nil`` if the ``validate_attribute_types`` flag is turned off.
1015
+ See the secion on :ref:`Uncastable Values <uncastable-values>` for more
1016
+ details.
1017
+
1010
1018
The class method ``demongoize`` does the inverse of ``mongoize``. It takes the raw object
1011
1019
from the MongoDB Ruby driver and converts it to an instance of your custom type.
1012
1020
In this case, the database driver returns an ``Array`` and we instantiate a ``Point`` from it.
You can’t perform that action at this time.
0 commit comments