module Tripod::Dirty
Public Instance Methods
attribute_change(attr)
click to toggle source
# File lib/tripod/dirty.rb, line 24 def attribute_change(attr) [ changed_attributes[attr], read_attribute(attr) ] if attribute_changed?(attr) end
attribute_changed?(attr)
click to toggle source
# File lib/tripod/dirty.rb, line 28 def attribute_changed?(attr) return false unless changed_attributes.has_key?(attr) (changed_attributes[attr] != read_attribute(attr)) end
attribute_will_change!(attr)
click to toggle source
# File lib/tripod/dirty.rb, line 20 def attribute_will_change!(attr) changed_attributes[attr] = read_attribute(attr) unless changed_attributes.has_key?(attr) end
changed()
click to toggle source
# File lib/tripod/dirty.rb, line 8 def changed changed_attributes.keys end
changed_attributes()
click to toggle source
# File lib/tripod/dirty.rb, line 4 def changed_attributes @changed_attributes ||= {} end
changes()
click to toggle source
# File lib/tripod/dirty.rb, line 12 def changes changed.reduce({}) do |memo, attr| change = attribute_change(attr) memo[attr] = change if change memo end end
post_persist()
click to toggle source
# File lib/tripod/dirty.rb, line 33 def post_persist changed_attributes.clear end