Module: Cardiac::Model::Dirty

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

Overview

Cardiac::Model dirty attribute methods. Some of this has been “borrowed” from ActiveRecord.

Instance Method Summary collapse

Instance Method Details

#reloadObject

reload the record and clears changed attributes.

See Also:

  • ActiveRecord::Dirty#reload


39
40
41
42
43
44
# File 'lib/cardiac/model/dirty.rb', line 39

def reload(*) #:nodoc:
  super.tap do
    @previously_changed.clear
    @changed_attributes.clear
  end
end

#saveObject

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

See Also:

  • ActiveRecord::Dirty#save


18
19
20
21
22
23
24
# File 'lib/cardiac/model/dirty.rb', line 18

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

#save!Object

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

See Also:

  • ActiveRecord::Dirty#save!


29
30
31
32
33
34
# File 'lib/cardiac/model/dirty.rb', line 29

def save!(*) #:nodoc:
  super.tap do
    @previously_changed = changes
    @changed_attributes.clear
  end
end