Module: DataMapper::Resource

Included in:
Application, AuditRecord, Comment, DashConfig, ExportFormat, Flag, Link, MonthlyAllocation, Notification, Organization, RecordType, Section, Setting, Test, User, VulnType, Vulnerability
Defined in:
lib/dataMapperMakeDirty.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) make_dirty(*attributes)

Explicitly mark all given attributes of a DM Resource as dirty to force save. Useful for Object properties.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/dataMapperMakeDirty.rb', line 16

def make_dirty(*attributes)
	if attributes.empty?
		return
	end
	unless self.clean?
		self.save
	end
	dirty_state = DataMapper::Resource::PersistenceState::Dirty.new(self)
	attributes.each do |attribute|
		property = self.class.properties[attribute]
		dirty_state.original_attributes[property] = nil
		self.persistence_state = dirty_state
	end
end