module Property::Dirty

This module implement ActiveRecord::Dirty functionalities with Property attributes. It enables the usual ‘changed?’ and ‘changes’ to include property changes. Unlike dirty, ‘foo_changed?’ and ‘foo_was’ are not defined in the model and should be replaced by prop.foo_changed? and prop.foo_was.

If you need to find the property changes only, you can use prop.changes or prop.changed?

Private Class Methods

included(base) click to toggle source
# File lib/property/dirty.rb, line 13
def self.included(base)
  base.class_eval do
    alias_method_chain :changed?, :properties
    alias_method_chain :changed,  :properties
    alias_method_chain :changes,  :properties
  end
end

Private Instance Methods

changed_with_properties() click to toggle source
# File lib/property/dirty.rb, line 25
def changed_with_properties
  changed_without_properties + properties.changed
end
changed_with_properties?() click to toggle source
# File lib/property/dirty.rb, line 21
def changed_with_properties?
  changed_without_properties? || properties.changed?
end
changes_with_properties() click to toggle source
# File lib/property/dirty.rb, line 29
def changes_with_properties
  changes_without_properties.merge properties.changes
end