Sha256: c0142d9721e01e42a7afb02371f8ea9a9d2f206ef6009bb6be6c183e2a047281
Contents?: true
Size: 730 Bytes
Versions: 2
Compression:
Stored size: 730 Bytes
Contents
module MongoModel module Attributes module Dirty def []=(key, value) attr = key.to_s # The attribute already has an unsaved change. if changed.include?(attr) old = changed[attr] changed.delete(attr) if value == old else old = clone_attribute_value(attr) changed[attr] = old unless value == old end super end def changed @changed ||= {} end private def clone_attribute_value(attribute_name) value = self[attribute_name.to_sym] value.duplicable? ? value.clone : value rescue TypeError, NoMethodError value end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mongomodel-0.2.5 | lib/mongomodel/attributes/dirty.rb |
mongomodel-0.2.4 | lib/mongomodel/attributes/dirty.rb |