Sha256: 331be543525a3c277a227d7d0f68429e2dca3f30720804c701816dff50d82c1a

Contents?: true

Size: 861 Bytes

Versions: 12

Compression:

Stored size: 861 Bytes

Contents

module CassandraObject
  module AttributeMethods
    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 = {}
        end
        status
      end

      # <tt>reload</tt> the record and clears changed attributes.
      def reload
        super.tap do
          @previously_changed.try :clear
          @changed_attributes.try :clear
        end
      end

      def write_attribute(name, value)
        name = name.to_s
        old = read_attribute(name)

        super

        unless attribute_changed?(name) || old == read_attribute(name)
          changed_attributes[name] = old
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
extendi-cassandra_object-1.0.7 lib/cassandra_object/attribute_methods/dirty.rb
extendi-cassandra_object-1.0.6 lib/cassandra_object/attribute_methods/dirty.rb
extendi-cassandra_object-1.0.5 lib/cassandra_object/attribute_methods/dirty.rb
extendi-cassandra_object-1.0.4 lib/cassandra_object/attribute_methods/dirty.rb
extendi-cassandra_object-1.0.1 lib/cassandra_object/attribute_methods/dirty.rb
extendi-cassandra_object-1.0.0 lib/cassandra_object/attribute_methods/dirty.rb
gotime-cassandra_object-4.12.2 lib/cassandra_object/attribute_methods/dirty.rb
gotime-cassandra_object-4.12.1 lib/cassandra_object/attribute_methods/dirty.rb
gotime-cassandra_object-4.12.0 lib/cassandra_object/attribute_methods/dirty.rb
gotime-cassandra_object-4.11.6 lib/cassandra_object/attribute_methods/dirty.rb
gotime-cassandra_object-4.11.5 lib/cassandra_object/attribute_methods/dirty.rb
gotime-cassandra_object-4.11.4 lib/cassandra_object/attribute_methods/dirty.rb