@@ -600,3 +600,26 @@ returns ``true``:
600
600
b.name == "Depeche Mode"
601
601
end
602
602
# => #<Band _id: 62c58e383282a4cbe82bd74b, name: "Depeche Mode">
603
+
604
+
605
+ Changes to the ``attributes_before_type_cast`` Hash
606
+ ---------------------------------------------------
607
+
608
+ The ``attributes_before_type_cast`` hash has been changed to function more like
609
+ ActiveRecord:
610
+
611
+ - On instantiation of a new model (without parameters), the
612
+ ``attributes_before_type_cast`` hash has the same contents as the
613
+ ``attributes`` hash. If parameters are passed to the initializer, those
614
+ values will be stored in the ``attributes_before_type_cast`` hash before
615
+ they are ``mongoized``.
616
+ - When assigning a value to the model, the ``mongoized`` value (i.e. when
617
+ assiging '1' to an Integer field, it is ``mongoized`` to 1) is stored in
618
+ the ``attributes`` hash, whereas the raw value (i.e. '1') is stored in the
619
+ ``attributes_before_type_cast`` hash.
620
+ - When saving, creating (i.e. using the ``create!`` method), or reloading the
621
+ model, the ``attributes_before_type_cast`` hash is reset to have the same
622
+ contents as the ``attributes`` hash.
623
+ - When reading a document from the database, the ``attributes_before_type_cast``
624
+ hash contains the attributes as they appear in the database, as opposed to
625
+ their ``demongoized`` form.
0 commit comments