Sha256: 30bb191df1749631ca535bcc16ff8f5e6bfec73b1e455c0b0b3c8d24ef4aecff

Contents?: true

Size: 515 Bytes

Versions: 2

Compression:

Stored size: 515 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
        {}.merge(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.7 lib/mongomodel/concerns/attribute_methods/dirty.rb
mongomodel-0.2.6 lib/mongomodel/concerns/attribute_methods/dirty.rb