module Virtus::DirtyAttribute
Dirty Tracking¶ ↑
Dirty Tracking is an optional module that you include only if you need it.
Public Class Methods
included(base)
click to toggle source
# File lib/virtus/dirty_attribute.rb, line 59 def self.included(base) base.extend ClassMethods end
Public Instance Methods
attribute_clean!(name)
click to toggle source
# File lib/virtus/dirty_attribute.rb, line 94 def attribute_clean!(name) dirty_session.attribute_clean!(name) end
attribute_dirty!(name, value)
click to toggle source
# File lib/virtus/dirty_attribute.rb, line 90 def attribute_dirty!(name, value) dirty_session.dirty!(name, value) end
attribute_dirty?(name, options = {})
click to toggle source
# File lib/virtus/dirty_attribute.rb, line 71 def attribute_dirty?(name, options = {}) result = dirty_session.dirty?(name) result &&= options[:to] == dirty_attributes[name] if options.key?(:to) result &&= options[:from] == original_attributes[name] if options.key?(:from) result end
clean!()
click to toggle source
# File lib/virtus/dirty_attribute.rb, line 78 def clean! dirty_session.clean! end
clean?()
click to toggle source
# File lib/virtus/dirty_attribute.rb, line 67 def clean? !dirty? end
dirty?()
click to toggle source
# File lib/virtus/dirty_attribute.rb, line 63 def dirty? dirty_session.dirty? end
dirty_attributes()
click to toggle source
# File lib/virtus/dirty_attribute.rb, line 82 def dirty_attributes dirty_session.dirty_attributes end
original_attributes()
click to toggle source
# File lib/virtus/dirty_attribute.rb, line 86 def original_attributes dirty_session.original_attributes end
Private Instance Methods
dirty_session()
click to toggle source
# File lib/virtus/dirty_attribute.rb, line 100 def dirty_session @_dirty_session ||= Session.new(self) end