Module: CassandraObject::AttributeMethods::Dirty

Extended by:
ActiveSupport::Concern
Includes:
ActiveModel::Dirty
Included in:
Base
Defined in:
lib/cassandra_object/attribute_methods/dirty.rb

Instance Method Summary collapse

Instance Method Details

#reloadObject

reload the record and clears changed attributes.



17
18
19
20
21
22
# File 'lib/cassandra_object/attribute_methods/dirty.rb', line 17

def reload
  super.tap do
    @previously_changed.try :clear
    @changed_attributes.try :clear
  end
end

#saveObject

Attempts to save the record and clears changed attributes if successful.



8
9
10
11
12
13
14
# File 'lib/cassandra_object/attribute_methods/dirty.rb', line 8

def save(*) #:nodoc:
  if status = super
    @previously_changed = changes
    @changed_attributes = {}
  end
  status
end

#write_attribute(name, value) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/cassandra_object/attribute_methods/dirty.rb', line 24

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