Sha256: 53258d9eaa0ad9abac2e18b4727ef9f9871d73874a83eafc930744a37d059f14

Contents?: true

Size: 791 Bytes

Versions: 52

Compression:

Stored size: 791 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

    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

52 entries across 52 versions & 2 rubygems

Version Path
sessionm-cassandra_object-2.2.44 lib/cassandra_object/dirty.rb
sessionm-cassandra_object-2.2.43 lib/cassandra_object/dirty.rb
sessionm-cassandra_object-2.2.42 lib/cassandra_object/dirty.rb
sessionm-cassandra_object-2.2.41 lib/cassandra_object/dirty.rb
sessionm-cassandra_object-2.2.40 lib/cassandra_object/dirty.rb
sessionm-cassandra_object-2.2.39 lib/cassandra_object/dirty.rb
sessionm-cassandra_object-2.2.38 lib/cassandra_object/dirty.rb
sessionm-cassandra_object-2.2.37 lib/cassandra_object/dirty.rb
sessionm-cassandra_object-2.2.36 lib/cassandra_object/dirty.rb
sessionm-cassandra_object-2.2.35 lib/cassandra_object/dirty.rb
sessionm-cassandra_object-2.2.34 lib/cassandra_object/dirty.rb
sessionm-cassandra_object-2.2.33 lib/cassandra_object/dirty.rb
sessionm-cassandra_object-2.2.32 lib/cassandra_object/dirty.rb
sessionm-cassandra_object-2.2.31 lib/cassandra_object/dirty.rb
sessionm-cassandra_object-2.2.30 lib/cassandra_object/dirty.rb
sessionm-cassandra_object-2.2.29 lib/cassandra_object/dirty.rb
sessionm-cassandra_object-2.2.28 lib/cassandra_object/dirty.rb
sessionm-cassandra_object-2.2.27 lib/cassandra_object/dirty.rb
sessionm-cassandra_object-2.2.26 lib/cassandra_object/dirty.rb
sessionm-cassandra_object-2.2.24 lib/cassandra_object/dirty.rb