Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

override #save to add reset_changes

  • Loading branch information...
commit 654b778dcb50920e2632a797bf838a9fec84159d 1 parent d30d1c1
@jamesgolick authored
Showing with 11 additions and 2 deletions.
  1. +1 −1  lib/friendly/document.rb
  2. +10 −1 lib/friendly/document/attributes.rb
View
2  lib/friendly/document.rb
@@ -38,10 +38,10 @@ def table_name
end
include Associations
- include Attributes
include Convenience
include Scoping
include Storage
+ include Attributes
def table_name
self.class.table_name
View
11 lib/friendly/document/attributes.rb
@@ -78,7 +78,7 @@ def changed
# Reset all the changes to this object.
#
def reset_changes
- changed.each { |c| not_changed(c) }
+ changed.each { |c| not_changed(c) }.clear
end
# Reset the changed-ness of one attribute.
@@ -88,6 +88,15 @@ def not_changed(attribute)
changed.delete(attribute)
end
+ # Override #save to reset changes afterwards
+ #
+ # @override
+ #
+ def save
+ super
+ reset_changes
+ end
+
protected
def assert_no_duplicate_keys(hash)
if hash.keys.map { |k| k.to_s }.uniq.length < hash.keys.length
Please sign in to comment.
Something went wrong with that request. Please try again.