Sha256: f079b84644632f17ddbb479f3a22a614405daf62be3c8ebc07b937674dd00ea2

Contents?: true

Size: 847 Bytes

Versions: 19

Compression:

Stored size: 847 Bytes

Contents

class Acfs::Resource
  #
  # Thin wrapper around ActiveModel::Dirty
  #
  module Dirty
    extend ActiveSupport::Concern
    include ActiveModel::Dirty

    # @api private
    #
    # Resets all changes. Does not touch previous changes.
    #
    def reset_changes
      changed_attributes.clear
    end

    # @api private
    #
    # Save current changes as previous changes and reset
    # current one.
    #
    def swap_changes
      @previously_changed = changes
      reset_changes
    end

    # @api private
    #
    def save!(*)
      super.tap {|_| swap_changes }
    end

    # @api private
    #
    def loaded!
      reset_changes
      super
    end

    # @api private
    #
    def write_raw_attribute(name, value, opts = {})
      attribute_will_change! name if opts[:change].nil? || opts[:change]
      super
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
acfs-0.49.1 lib/acfs/resource/dirty.rb
acfs-1.1.1 lib/acfs/resource/dirty.rb
acfs-0.49.0 lib/acfs/resource/dirty.rb
acfs-1.1.0 lib/acfs/resource/dirty.rb
acfs-0.48.2 lib/acfs/resource/dirty.rb
acfs-1.0.1 lib/acfs/resource/dirty.rb
acfs-0.48.1 lib/acfs/resource/dirty.rb
acfs-1.0.0 lib/acfs/resource/dirty.rb
acfs-0.48.0 lib/acfs/resource/dirty.rb
acfs-0.47.0 lib/acfs/resource/dirty.rb
acfs-0.46.0 lib/acfs/resource/dirty.rb
acfs-0.45.0 lib/acfs/resource/dirty.rb
acfs-0.44.0 lib/acfs/resource/dirty.rb
acfs-0.43.2 lib/acfs/resource/dirty.rb
acfs-0.43.1 lib/acfs/resource/dirty.rb
acfs-0.43.0 lib/acfs/resource/dirty.rb
acfs-1.0.0.dev.1.b305 lib/acfs/resource/dirty.rb
acfs-1.0.0.dev.1.b298 lib/acfs/resource/dirty.rb
acfs-1.0.0.dev.1.b297 lib/acfs/resource/dirty.rb