Skip to content

Commit 8e8e89c

Browse files
neilshwekyp-mongo
andauthored
MONGOID-4403 Support Dirty Tracking changed from/to (#5432)
* MONGOID-4403 Support Dirty Tracking changed from/to * Apply suggestions from code review Co-authored-by: Oleg Pudeyev <[email protected]> * MONGOID-4403 add false example Co-authored-by: Oleg Pudeyev <[email protected]>
1 parent f1e819d commit 8e8e89c

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

source/release-notes/mongoid-8.1.txt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,32 @@ from the ``_translations`` hash:
116116

117117
See the section on :ref:`Localize :present Field Option <present-fields>` for
118118
more details on how these are used.
119+
120+
121+
Added ``:to`` and ``:from`` options to ``attribute_changed?``
122+
-------------------------------------------------------------
123+
124+
Mongoid 8.1 adds the ``:to`` and ``:from`` options on the ``attribute_changed?``
125+
method. These options can be used to inquire whether the attribute has been changed
126+
to or from a certain value:
127+
128+
.. code:
129+
130+
class Person
131+
include Mongoid::Document
132+
field :name, type: String
133+
end
134+
135+
person = Person.create!(name: "Trout")
136+
person.name = "Ohtani"
137+
138+
person.name_changed?
139+
# => true
140+
person.name_changed?(from: "Trout")
141+
# => true
142+
person.name_changed?(to: "Ohtani")
143+
# => true
144+
person.name_changed?(from: "Trout", to: "Ohtani")
145+
# => true
146+
person.name_changed?(from: "Trout", to: "Fletcher")
147+
# => false

0 commit comments

Comments
 (0)