Permalink
Browse files

Allow using #value_changed? for key with name 'value'

  • Loading branch information...
bearded
bearded committed May 11, 2011
1 parent 7d31285 commit 1d9bbb4cac954876b5213e21a232bb99004a5b3d
Showing with 3 additions and 3 deletions.
  1. +3 −3 lib/mongo_mapper/plugins/dirty.rb
@@ -53,15 +53,15 @@ def write_key(key, value)
key = key.to_s
old = read_key(key)
attribute_will_change!(key) if attribute_should_change?(key, old, value)
changed_attributes.delete(key) unless value_changed?(key, attribute_was(key), value)
changed_attributes.delete(key) unless attribute_value_changed?(key, attribute_was(key), value)
super(key, value)
end
def attribute_should_change?(key, old, value)
attribute_changed?(key) == false && value_changed?(key, old, value)
attribute_changed?(key) == false && attribute_value_changed?(key, old, value)
end
def value_changed?(key_name, old, value)
def attribute_value_changed?(key_name, old, value)
value = nil if keys[key_name.to_s].number? && value.blank?
old != value
end

0 comments on commit 1d9bbb4

Please sign in to comment.