Sha256: 66ea5b524ae31a20713b22046360a14e4a75684385dfde2494581556f2ba1344
Contents?: true
Size: 860 Bytes
Versions: 7
Compression:
Stored size: 860 Bytes
Contents
module Dynamoid module Dirty extend ActiveSupport::Concern include ActiveModel::Dirty module ClassMethods def from_database(*) super.tap { |d| d.changed_attributes.clear } end end def save(*) clear_changes { super } end def reload super.tap { clear_changes } end def clear_changes previous = changes (block_given? ? yield : true).tap do |result| unless result == false #failed validation; nil is OK. @previously_changed = previous changed_attributes.clear end end end def write_attribute(name, value) attribute_will_change!(name) unless self.read_attribute(name) == value super end protected def attribute_method?(attr) super || self.class.attributes.has_key?(attr.to_sym) end end end
Version data entries
7 entries across 7 versions & 2 rubygems