Module: MongoODM::Document::AttributeMethods::Dirty::InstanceMethods

Defined in:
lib/mongo_odm/document/attribute_methods/dirty.rb

Instance Method Summary collapse

Instance Method Details

#initialize_with_dirty(*args) ⇒ Object



21
22
23
24
25
# File 'lib/mongo_odm/document/attribute_methods/dirty.rb', line 21

def initialize_with_dirty(*args)
  initialize_without_dirty(*args)
  changed_attributes.clear
  self
end

#reload_with_dirty(*args) ⇒ Object



40
41
42
43
44
45
# File 'lib/mongo_odm/document/attribute_methods/dirty.rb', line 40

def reload_with_dirty(*args)
  reload_without_dirty(*args).tap do
    @previously_changed = nil
    changed_attributes.clear
  end
end

#save_with_dirty(*args) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/mongo_odm/document/attribute_methods/dirty.rb', line 32

def save_with_dirty(*args)
  if status = save_without_dirty(*args)
    @previously_changed = changes
    changed_attributes.clear
  end
  status
end

#write_attribute_with_dirty(attr_name, value) ⇒ Object



27
28
29
30
# File 'lib/mongo_odm/document/attribute_methods/dirty.rb', line 27

def write_attribute_with_dirty(attr_name, value)
  send("#{attr_name}_will_change!") if respond_to?("#{attr_name}_will_change!")
  write_attribute_without_dirty(attr_name, value)
end