lib/activefacts/vocabulary/extensions.rb in activefacts-0.7.1 vs lib/activefacts/vocabulary/extensions.rb in activefacts-0.7.2

- old
+ new

@@ -56,11 +56,11 @@ def preferred_reference fact_type.preferred_reading.role_sequence.all_role_ref.detect{|rr| rr.role == self } end end - class JoinPath + class Join def column_name(joiner = '-') concept == input_role.concept ? input_role.preferred_reference.role_name(joiner) : Array(concept.name) end def describe @@ -70,12 +70,12 @@ end end class RoleRef def describe - # The reference traverses the JoinPaths in sequence to the final role: - all_join_path.sort_by{|jp| jp.join_step}.map{ |jp| jp.describe + "." }*"" + role_name + # The reference traverses the Joins in sequence to the final role: + all_join.sort_by{|jp| jp.join_step}.map{ |jp| jp.describe + "." }*"" + role_name end def role_name(joiner = "-") name_array = if role.fact_type.all_role.size == 1 @@ -84,17 +84,17 @@ role.role_name || [leading_adjective, role.concept.name, trailing_adjective].compact.map{|w| w.split(/\s/)}.flatten end return joiner ? Array(name_array)*joiner : Array(name_array) end - # Two RoleRefs are equal if they have the same role and JoinPaths with matching roles + # Two RoleRefs are equal if they have the same role and Joins with matching roles def ==(role_ref) RoleRef === role_ref && role_ref.role == role && - all_join_path.size == role_ref.all_join_path.size && - !all_join_path.sort_by{|j|j.join_step}. - zip(role_ref.all_join_path.sort_by{|j|j.join_step}). + all_join.size == role_ref.all_join.size && + !all_join.sort_by{|j|j.join_step}. + zip(role_ref.all_join.sort_by{|j|j.join_step}). detect{|j1,j2| j1.input_role != j2.input_role || j1.output_role != j2.output_role } end @@ -373,9 +373,19 @@ [ ((min && min > 0 && min != max) ? "at least #{min == 1 ? "one" : min.to_s}" : nil), ((max && min != max) ? "at most #{max == 1 ? "one" : max.to_s}" : nil), ((max && min == max) ? "#{max == 1 ? "one" : max.to_s}" : nil) ].compact * " and" + end + + def describe + role_sequence.describe + " occurs " + frequency + " time" + end + end + + class TypeInheritance + def describe(role = nil) + "#{subtype.name} is a kind of #{supertype.name}" end end end end