DB::ModelSourceDBModelRecord

module Record

Nested

Definitions

def persisted?

A record which has a valid primary key is considered to be persisted.

Implementation

def persisted?
	self.class.key_columns.map do |field|
		@attributes[field] or return false
	end
end

def flatten!

Moves values from @changed into @attributes.

Implementation

def flatten!
	return nil unless @changed&.any?
	
	properties = self.class.properties
	changed = {}
	
	@changed.each do |key, value|
		if klass = properties[key]
			value = klass.dump(value)
		end
		
		changed[key] = @attributes[key] = value
	end
	
	@changed = nil
	
	return changed
end