Sha256: e2f9f061e0f3045053119e795065f349be38adb17e8c98295f29d4edd9337a57
Contents?: true
Size: 756 Bytes
Versions: 12
Compression:
Stored size: 756 Bytes
Contents
module MongoModel module Attributes module Dirty def []=(key, value) attr = key.to_sym # 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 ||= {}.with_indifferent_access 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
12 entries across 12 versions & 1 rubygems