module Dinamo::Model::Dirty
Public Instance Methods
attribute_changed?(attr)
click to toggle source
# File lib/dinamo/model/dirty.rb, line 34 def attribute_changed?(attr) changed.include?(attr.to_s) end
changed()
click to toggle source
# File lib/dinamo/model/dirty.rb, line 17 def changed changed_attributes.keys end
changed?()
click to toggle source
# File lib/dinamo/model/dirty.rb, line 21 def changed? !changed_attributes.empty? end
changed_attributes()
click to toggle source
# File lib/dinamo/model/dirty.rb, line 30 def changed_attributes @changed_attributes ||= ActiveSupport::HashWithIndifferentAccess.new end
changes()
click to toggle source
# File lib/dinamo/model/dirty.rb, line 25 def changes map = changed.map { |attr| [attr, attribute_change(attr)] } ActiveSupport::HashWithIndifferentAccess[map] end
changes_applied()
click to toggle source
# File lib/dinamo/model/dirty.rb, line 38 def changes_applied @previously_changed = changes @changed_attributes = ActiveSupport::HashWithIndifferentAccess.new end
clear_changes_information()
click to toggle source
# File lib/dinamo/model/dirty.rb, line 43 def clear_changes_information @previously_changed = ActiveSupport::HashWithIndifferentAccess.new @changed_attributes = ActiveSupport::HashWithIndifferentAccess.new end
clear_previous_attributes()
click to toggle source
# File lib/dinamo/model/dirty.rb, line 48 def clear_previous_attributes @previously_changed = ActiveSupport::HashWithIndifferentAccess.new end
Private Instance Methods
attribute_change(attr)
click to toggle source
# File lib/dinamo/model/dirty.rb, line 54 def attribute_change(attr) return unless attribute_changed?(attr) [previous_attributes[attr], changed_attributes[attr]] end
previous_attributes()
click to toggle source
# File lib/dinamo/model/dirty.rb, line 59 def previous_attributes @previous_attributes ||= ActiveSupport::HashWithIndifferentAccess.new end