Sha256: d139b3b1de00b34a1b1f339610247c11a63af4cdc668f5502ead2f872fe3e56b
Contents?: true
Size: 981 Bytes
Versions: 2
Compression:
Stored size: 981 Bytes
Contents
module CassandraObject module Dirty extend ActiveSupport::Concern include ActiveModel::Dirty # Attempts to +save+ the record and clears changed attributes if successful. def save(*) #:nodoc: if status = super @previously_changed = changes @changed_attributes.clear end status end # Attempts to <tt>save!</tt> the record and clears changed attributes if successful. def save!(*) #:nodoc: super.tap do @previously_changed = changes @changed_attributes.clear end end # <tt>reload</tt> the record and clears changed attributes. def reload super.tap do @previously_changed.try :clear @changed_attributes.clear end end def write_attribute(name, value) name = name.to_s unless attribute_changed?(name) old = read_attribute(name) changed_attributes[name] = old if old != value end super end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
gotime-cassandra_object-2.6.3 | lib/cassandra_object/dirty.rb |
gotime-cassandra_object-2.6.2 | lib/cassandra_object/dirty.rb |