Commit Graph

12 Commits

Author SHA1 Message Date
Rafael Mendonça França
c48c111bb2 Merge pull request #8791 from griffinmyers/master
Updated DirtyModel's @changed_attributes hash to be symbol/string agnostic

Conflicts:
	activemodel/CHANGELOG.md
2013-10-03 11:37:10 -03:00
Rafael Mendonça França
9aa1a3d853 Merge pull request #10816 from bogdan/less-dirty-dirty
Make AM::Dirty less dirty to plugin into AR or other library
2013-09-23 10:59:05 -03:00
William Myers
0e655873d4 DirtyModel uses a hash to keep track of any changes made to attributes
of an instance. When using the attribute_will_change! method, you must
supply a string and not a symbol or the *_changed? method will break
(because it is looking for the attribute name as a string in the keys
of the underlying hash). To remedy this, I simply made the underlying
hash a HashWithIndifferentAccess so it won't matter if you supply
the attribute name as a symbol or string to attribute_will_change!.
2013-05-27 23:41:26 -04:00
Attila Domokos
63333e600f Cleaning up ActiveModel::Dirty tests
* Clarifying what the #changed method returns
* Adding tests to describe what the #changed_attributes returns
* Updating test name based on pull request comment
* Moving the test lower in the file per pull request comment
2013-01-15 10:24:57 -05:00
Renato Mascarenhas
cf7ab6056a Reset attributes should not report changes.
When resetting an attribute, you expect it to return to the state it was
before any changes. Namely, this fixes this unexpected behavior:

~~~ruby
model.name = "Bob"
model.reset_name!
model.name_changed? #=> true
~~~
2012-12-01 16:58:09 -02:00
Francesco Rodriguez
00c94d7d94 updating define_attribute_methods documentation 2012-05-14 11:38:23 -05:00
Ian Stewart
eafa174bfd changing an attribute multiple times retains the correct original value 2011-06-28 22:18:24 -07:00
Tore Darell
2c8a4a53a8 Remove or fix non-working examples and add a few tests to Dirty [#5185 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-08-03 10:47:30 +02:00
Neeraj Singh
b462952886 Use better assertion methods for testing
[#4645 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-05-19 10:18:36 +02:00
Sam Pohlenz
3adaef8ae7 Restore changed_attributes method in ActiveModel::Dirty and loosen expectation on including class' initialize method.
[#4308 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2010-04-01 17:52:45 -07:00
José Valim
f1da7174cc Fix tests added in previous commit. 2010-03-27 11:04:21 +01:00
Jacob Atzen
a5d637d86c ActiveModel::Dirty#changes should return a HashWithIndifferentAccess [#4157 state:resolved]
Keep the Rails style of inject

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-03-27 10:48:32 +01:00