def child_key
@child_key ||= begin
child_key = nil
child_model.repository.scope do |r|
model_properties = child_model.properties(r.name)
child_key = parent_key.zip(@child_properties || []).map do |parent_property,property_name|
parent_name = Extlib::Inflection.underscore(Extlib::Inflection.demodulize(parent_model.base_model.name))
property_name ||= "#{parent_name}_#{parent_property.name}".to_sym
if model_properties.has_property?(property_name)
model_properties[property_name]
else
options = {}
[ :length, :precision, :scale ].each do |option|
options[option] = parent_property.send(option)
end
if child_model.respond_to?(:many_to_many)
options[:key] = true
end
child_model.property(property_name, parent_property.primitive, options)
end
end
end
PropertySet.new(child_key)
end
end