Sha256: 2ff485b381d1ffc3d37ed573838683855924075f2e9ece4bc56250c735d2dcba

Contents?: true

Size: 604 Bytes

Versions: 9

Compression:

Stored size: 604 Bytes

Contents

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
      end

      def save
        super.tap { changed_attributes.clear }
      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
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
gotime-cassandra_object-0.7.7 lib/cassandra_object/dirty.rb
gotime-cassandra_object-0.7.6 lib/cassandra_object/dirty.rb
gotime-cassandra_object-0.7.5 lib/cassandra_object/dirty.rb
gotime-cassandra_object-0.7.4 lib/cassandra_object/dirty.rb
gotime-cassandra_object-0.7.3 lib/cassandra_object/dirty.rb
gotime-cassandra_object-0.7.2 lib/cassandra_object/dirty.rb
gotime-cassandra_object-0.7.1 lib/cassandra_object/dirty.rb
gotime-cassandra_object-0.6.1 lib/cassandra_object/dirty.rb
cassandra_object-0.6.0.pre lib/cassandra_object/dirty.rb