1 ManifestBase.require_modules "manifest/model/association/",
2 %w|belongs_to has_many has_one|
6 class Association < ManifestBase::Values
7 include AssociationModule
9 attr :belongs_to, :has_many, :has_one
13 @values['belongs_to'] ||= {}
14 @values['has_many'] ||= {}
15 @values['has_one'] ||= {}
20 @belongs_to = ManifestBase.load_name_values self, @values, 'belongs_to', BelongsTo
21 @has_many = ManifestBase.load_name_values self, @values, 'has_many', HasMany
22 @has_one = ManifestBase.load_name_values self, @values, 'has_one', HasOne
30 @belongs_to.each do |name, belongs_to_manifest|
32 next unless pm.element?
33 if pm.my_peta.type == 'element'
34 next unless belongs_to_manifest.model.my_peta.type == 'root'
36 if pm.my_peta.type == 'leaf'
37 next unless belongs_to_manifest.model.my_peta.type == 'binder'
39 yield belongs_to_manifest.model
43 def child_element_name child_model
44 if has_one? child_model
47 child_model.table_name
51 def has_one? child_model
52 if @has_one[child_model.item_name]