Sha256: 30c44501962030ec00a842f59b589cf8dbac4fcd6ebc86b0fd3618b38a2e6879
Contents?: true
Size: 856 Bytes
Versions: 3
Compression:
Stored size: 856 Bytes
Contents
module Superstore 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
superstore-1.0.3 | lib/superstore/attribute_methods/dirty.rb |
superstore-1.0.2 | lib/superstore/attribute_methods/dirty.rb |
superstore-1.0.0 | lib/superstore/attribute_methods/dirty.rb |