Class: Relaxo::Model::Properties::HasMany

Inherits:
HasOne show all
Defined in:
lib/relaxo/model/properties/composite.rb

Instance Method Summary collapse

Methods inherited from BelongsTo

[], #initialize

Constructor Details

This class inherits a constructor from Relaxo::Model::Properties::BelongsTo

Instance Method Details

#convert_from_primative(dataset, value) ⇒ Object



98
99
100
# File 'lib/relaxo/model/properties/composite.rb', line 98

def convert_from_primative(dataset, value)
	value.collect{|id| @klass.fetch(dataset, id)}
end

#convert_to_primative(documents) ⇒ Object



90
91
92
93
94
95
96
# File 'lib/relaxo/model/properties/composite.rb', line 90

def convert_to_primative(documents)
	documents.each do |document|
		raise ArgumentError.new("Document must be saved before adding to relationship") unless document.persisted?
	end
	
	documents.collect{|document| document.paths.first}
end