Sha256: b5ae97bef26a0fa627e5c392cb3f4aa08fa5ae3c2959dde7043b455abfa184c1

Contents?: true

Size: 945 Bytes

Versions: 111

Compression:

Stored size: 945 Bytes

Contents

module Acfs
  module Model

    # 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 = {}) # :nodoc:
        attribute_will_change! name if opts[:change].nil? or opts[:change]
        super
      end
    end
  end
end

Version data entries

111 entries across 111 versions & 1 rubygems

Version Path
acfs-0.34.0 lib/acfs/model/dirty.rb
acfs-0.33.1.1.b285 lib/acfs/model/dirty.rb
acfs-0.33.1.1.b281 lib/acfs/model/dirty.rb
acfs-0.33.1 lib/acfs/model/dirty.rb
acfs-0.33.0.1.b278 lib/acfs/model/dirty.rb
acfs-0.33.0 lib/acfs/model/dirty.rb
acfs-0.32.1.1.b277 lib/acfs/model/dirty.rb
acfs-0.32.1.1.b276 lib/acfs/model/dirty.rb
acfs-0.32.1.1.b275 lib/acfs/model/dirty.rb
acfs-0.32.1.1.b274 lib/acfs/model/dirty.rb
acfs-0.32.1.1.b272 lib/acfs/model/dirty.rb
acfs-0.32.1 lib/acfs/model/dirty.rb
acfs-0.32.0.1.b270 lib/acfs/model/dirty.rb
acfs-0.31.0.1.b269 lib/acfs/model/dirty.rb
acfs-0.32.0 lib/acfs/model/dirty.rb
acfs-0.31.0.1.b265 lib/acfs/model/dirty.rb
acfs-0.31.0.1.b263 lib/acfs/model/dirty.rb
acfs-0.31.0 lib/acfs/model/dirty.rb
acfs-0.30.0.1.b262 lib/acfs/model/dirty.rb
acfs-0.30.0.1.b261 lib/acfs/model/dirty.rb