Sha256: e3bb9a6bf840bac4f5ea1a19cfc308a055c0d53052b2e6d59b45456b0553247e

Contents?: true

Size: 569 Bytes

Versions: 8

Compression:

Stored size: 569 Bytes

Contents

module MongoModel
  module AttributeMethods
    module Dirty
      extend ActiveSupport::Concern
      
      include ActiveModel::Dirty
      
      included do
        before_save { @previously_changed = changes }
        after_save { changed_attributes.clear }
      end
      
      # Returns the attributes as they were before any changes were made to the document.
      def original_attributes
        {}.merge(attributes).merge(changed_attributes)
      end
    
    protected
      def changed_attributes
        attributes.changed
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
mongomodel-0.2.15 lib/mongomodel/concerns/attribute_methods/dirty.rb
mongomodel-0.2.14 lib/mongomodel/concerns/attribute_methods/dirty.rb
mongomodel-0.2.13 lib/mongomodel/concerns/attribute_methods/dirty.rb
mongomodel-0.2.12 lib/mongomodel/concerns/attribute_methods/dirty.rb
mongomodel-0.2.11 lib/mongomodel/concerns/attribute_methods/dirty.rb
mongomodel-0.2.10 lib/mongomodel/concerns/attribute_methods/dirty.rb
mongomodel-0.2.9 lib/mongomodel/concerns/attribute_methods/dirty.rb
mongomodel-0.2.8 lib/mongomodel/concerns/attribute_methods/dirty.rb