diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-06-11 13:39:46 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-06-11 13:39:46 -0700 |
commit | 47617ecdf7b4c6ee8dd0a5092b82c792fc1cad4a (patch) | |
tree | 972ef79cd22dcdc801b8efc759508f6897e72ed3 /activemodel/lib | |
parent | 4b824b052046f3ec0cea6cad2adc3ce0bcd5c9fe (diff) | |
download | rails-47617ecdf7b4c6ee8dd0a5092b82c792fc1cad4a.tar.gz rails-47617ecdf7b4c6ee8dd0a5092b82c792fc1cad4a.tar.bz2 rails-47617ecdf7b4c6ee8dd0a5092b82c792fc1cad4a.zip |
expose a few attribute changed methods
Diffstat (limited to 'activemodel/lib')
-rw-r--r-- | activemodel/lib/active_model/dirty.rb | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/activemodel/lib/active_model/dirty.rb b/activemodel/lib/active_model/dirty.rb index cafdb946c0..ea5ddf71de 100644 --- a/activemodel/lib/active_model/dirty.rb +++ b/activemodel/lib/active_model/dirty.rb @@ -142,23 +142,23 @@ module ActiveModel @changed_attributes ||= {} end - private + # Handle <tt>*_changed?</tt> for +method_missing+. + def attribute_changed?(attr) + changed_attributes.include?(attr) + end - # Handle <tt>*_changed?</tt> for +method_missing+. - def attribute_changed?(attr) - changed_attributes.include?(attr) - end + # Handle <tt>*_was</tt> for +method_missing+. + def attribute_was(attr) + attribute_changed?(attr) ? changed_attributes[attr] : __send__(attr) + end + + private # Handle <tt>*_change</tt> for +method_missing+. def attribute_change(attr) [changed_attributes[attr], __send__(attr)] if attribute_changed?(attr) end - # Handle <tt>*_was</tt> for +method_missing+. - def attribute_was(attr) - attribute_changed?(attr) ? changed_attributes[attr] : __send__(attr) - end - # Handle <tt>*_will_change!</tt> for +method_missing+. def attribute_will_change!(attr) return if attribute_changed?(attr) |