Module: Ripple::AttributeMethods::Dirty

Extended by:
ActiveSupport::Concern
Includes:
ActiveModel::Dirty
Defined in:
lib/ripple/attribute_methods/dirty.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#changed?Boolean

Determines if the document has any chnages. documents at any level, have changed.

Returns:

  • (Boolean)

    true if this document, or any of its embedded



44
45
46
47
48
# File 'lib/ripple/attribute_methods/dirty.rb', line 44

def changed?
  super || self.class.embedded_associations.any? do |association|
    send(association.name).has_changed_documents?
  end
end

#initialize(*args) ⇒ Object



36
37
38
39
# File 'lib/ripple/attribute_methods/dirty.rb', line 36

def initialize(*args)
  super
  changed_attributes.clear
end

#really_save(*args) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/ripple/attribute_methods/dirty.rb', line 20

def really_save(*args)
  if result = super
    @previously_changed = changes
    changed_attributes.clear
  end
  result
end

#reloadObject



29
30
31
32
33
# File 'lib/ripple/attribute_methods/dirty.rb', line 29

def reload
  super.tap do
    changed_attributes.clear
  end
end