lib/cassandra_object/dirty.rb in gotime-cassandra_object-0.9.1 vs lib/cassandra_object/dirty.rb in gotime-cassandra_object-2.0.0

- old
+ new

@@ -1,27 +1,32 @@ module CassandraObject module Dirty extend ActiveSupport::Concern include ActiveModel::Dirty - module InstanceMethods - def attributes_changed!(attributes) - attributes.each do |attr_name| - attribute_will_change!(attr_name) - end + # 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 - def save(options={}) - super.tap { changed_attributes.clear } + # 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 - 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 + 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