class ActiveFacts::Metamodel::Concept
Public Instance Methods
describe()
click to toggle source
# File lib/activefacts/metamodel/extensions.rb, line 76 def describe case when object_type; "#{object_type.class.basename} #{object_type.name.inspect}" when fact_type; "FactType #{fact_type.default_reading.inspect}" when role; "Role in #{role.fact_type.describe(role)}" when constraint; constraint.describe when instance; "Instance #{instance.verbalise}" when fact; "Fact #{fact.verbalise}" when query; query.describe when context_note; "ContextNote#{context_note.verbalise}" when unit; "Unit #{unit.describe}" when population; "Population: #{population.name}" when transform_rule; "Transform Rule: #{transform_rule.describe}" else raise "ROGUE CONCEPT OF NO TYPE" end end
embodied_as()
click to toggle source
# File lib/activefacts/metamodel/extensions.rb, line 94 def embodied_as case when object_type; object_type when fact_type; fact_type when role; role when constraint; constraint when instance; instance when fact; fact when query; query when context_note; context_note when unit; unit when population; population when transform_rule; transform_rule else raise "ROGUE CONCEPT OF NO TYPE" end end
precursors()
click to toggle source
Return an array of all Concepts that must be defined before this concept can be defined:
# File lib/activefacts/metamodel/extensions.rb, line 113 def precursors case body = embodied_as when ActiveFacts::Metamodel::ValueType [ body.supertype, body.unit ] + body.all_value_type_parameter.map{|f| f.facet_value_type } + body.all_value_type_parameter_restriction.map{|vr| vr.value.unit} when ActiveFacts::Metamodel::EntityType # You can't define the preferred_identifier fact types until you define the entity type, # but the objects which play the identifying roles must be defined: body.preferred_identifier.role_sequence.all_role_ref.map {|rr| rr.role.object_type } + # You can't define the objectified fact type until you define the entity type: # [ body.fact_type ] # If it's an objectification body.all_type_inheritance_as_subtype.map{|ti| ti.supertype} # If it's a subtype when FactType body.all_role.map(&:object_type) when Role # We don't consider roles as they cannot be separately defined [] when ActiveFacts::Metamodel::PresenceConstraint body.role_sequence.all_role_ref.map do |rr| rr.role.fact_type end when ActiveFacts::Metamodel::ValueConstraint [ body.role_as_role_value_constraint ? body.role_as_role_value_constraint.fact_type : nil, body.value_type ] + body.all_allowed_range.map do |ar| [ ar.value_range.minimum_bound, ar.value_range.maximum_bound ].compact.map{|b| b.value.unit} end when ActiveFacts::Metamodel::SubsetConstraint body.subset_role_sequence.all_role_ref.map{|rr| rr.role.fact_type } + body.superset_role_sequence.all_role_ref.map{|rr| rr.role.fact_type } when ActiveFacts::Metamodel::SetComparisonConstraint body.all_set_comparison_roles.map{|scr| scr.role_sequence.all_role_ref.map{|rr| rr.role.fact_type } } when ActiveFacts::Metamodel::RingConstraint [ body.role.fact_type, body.other_role.fact_type ] when Instance [ body.population, body.object_type, body.value ? body.value.unit : nil ] when Fact [ body.population, body.fact_type ] when Query body.all_variable.map do |v| [ v.object_type, v.value ? v.value.unit : nil, v.step ? v.step.fact_type : nil ] + v.all_play.map{|p| p.role.fact_type } end when ContextNote [] when Unit body.all_derivation_as_derived_unit.map{|d| d.base_unit } when Population [] else raise "ROGUE CONCEPT OF NO TYPE" end.flatten.compact.uniq.map{|c| c.concept } end