lib/activefacts/persistence/reference.rb in activefacts-0.7.3 vs lib/activefacts/persistence/reference.rb in activefacts-0.8.5

- old
+ new

@@ -115,11 +115,11 @@ case when is_unary if @to && @to.fact_type @to.name.camelwords else - @to_role.fact_type.preferred_reading.reading_text.gsub(/\{[0-9]\}/,'').strip.camelwords + @to_role.fact_type.preferred_reading.text.gsub(/\{[0-9]\}/,'').strip.camelwords end when @to && !@to_role # @to is an objectified fact type so @to_role is a phantom @to.name.camelwords when !@to_role # Self-value role of an independent ValueType @from.name.camelwords + ["Value"] @@ -258,21 +258,23 @@ when :unary ActiveFacts::Persistence::Reference.new(self, role).tabulate # A simple reference when :supertype # A subtype absorbs a reference to its supertype when separate, or all when partitioned # REVISIT: Or when partitioned - if role.fact_type.subtype.is_independent + raise hell unless role.fact_type.is_a?(ActiveFacts::Metamodel::TypeInheritance) + if role.fact_type.assimilation # assimilation == 'separate' or assimilation == 'partitioned' debug :references, "supertype #{name} doesn't absorb a reference to separate subtype #{role.fact_type.subtype.name}" else r = ActiveFacts::Persistence::Reference.new(self, role) r.to.absorbed_via = r debug :references, "supertype #{name} absorbs subtype #{r.to.name}" r.tabulate end when :subtype # This object is a supertype, which can absorb the subtype unless that's independent - if is_independent # REVISIT: Or when partitioned + raise hell unless role.fact_type.is_a?(ActiveFacts::Metamodel::TypeInheritance) + if role.fact_type.assimilation ActiveFacts::Persistence::Reference.new(self, role).tabulate # If partitioned, the supertype is absorbed into *each* subtype; a reference to the supertype needs to know which else # debug :references, "subtype #{name} is absorbed into #{role.fact_type.supertype.name}" end @@ -280,10 +282,11 @@ when :one_one r = ActiveFacts::Persistence::Reference.new(self, role) # Decide which way the one-to-one is likely to go; it will be flipped later if necessary. # Force the decision if just one is independent: + # REVISIT: Decide whether supertype assimilation can affect this r.tabulate and return if is_independent and !r.to.is_independent return if !is_independent and r.to.is_independent if is_a?(ValueType) # Never absorb an entity type into a value type @@ -333,28 +336,25 @@ end class Vocabulary def populate_all_references #:nodoc: debug :references, "Populating all concept references" do - all_feature.each do |feature| - next unless feature.is_a? Concept - feature.clear_references - feature.is_table = nil # Undecided; force an attempt to decide - feature.tentative = true # Uncertain + all_concept.each do |concept| + concept.clear_references + concept.is_table = nil # Undecided; force an attempt to decide + concept.tentative = true # Uncertain end - all_feature.each do |feature| - next unless feature.is_a? Concept - debug :references, "Populating references for #{feature.name}" do - feature.populate_references + all_concept.each do |concept| + debug :references, "Populating references for #{concept.name}" do + concept.populate_references end end end debug :references, "Finished concept references" do - all_feature.each do |feature| - next unless feature.is_a? Concept - next unless feature.references_from.size > 0 - debug :references, "#{feature.name}:" do - feature.references_from.each do |ref| + all_concept.each do |concept| + next unless concept.references_from.size > 0 + debug :references, "#{concept.name}:" do + concept.references_from.each do |ref| debug :references, "#{ref}" end end end end