lib/mongoid/genesis.rb in mongoid-genesis-0.0.2 vs lib/mongoid/genesis.rb in mongoid-genesis-0.0.3
- old
+ new
@@ -25,11 +25,15 @@
self.genesis.reverse
end
def write_and_preserve_attribute(field_name, value)
init_genesis if not self.genesis
- self.genesis.preserve field_name
- self.write_attribute(field_name, value)
+ if value and self.genesis.read_attribute(field_name) == value
+ self.restore_genesis(field_name)
+ else
+ self.genesis.preserve field_name
+ self.write_attribute(field_name, value)
+ end
end
end
end