Sha256: ad529af6b3f92bb86de5bc3427599ad08aadd76dec9d4b6655910d97af2967ac

Contents?: true

Size: 505 Bytes

Versions: 2

Compression:

Stored size: 505 Bytes

Contents

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mongomodel-0.2.5 lib/mongomodel/concerns/attribute_methods/dirty.rb
mongomodel-0.2.4 lib/mongomodel/concerns/attribute_methods/dirty.rb