Class: ActiveFacts::Metamodel::LinkFactType

Inherits:
FactType
  • Object
show all
Defined in:
lib/activefacts/vocabulary/metamodel.rb,
lib/activefacts/vocabulary/extensions.rb

Defined Under Namespace

Classes: ImplicitReading

Instance Attribute Summary

Attributes inherited from FactType

#check_and_add_spanning_uniqueness_constraint

Instance Method Summary collapse

Methods inherited from FactType

#all_reading_by_ordinal, #all_role_in_order, #compatible_readings, #create_implicit_fact_type_for_unary, #describe, #implicit_boolean_type, #internal_presence_constraints, #is_existential, #preferred_reading

Instance Method Details

#add_reading(implicit_reading) ⇒ Object



1069
1070
1071
1072
# File 'lib/activefacts/vocabulary/extensions.rb', line 1069

def add_reading implicit_reading
  @readings ||= []
  @readings << implicit_reading
end

#all_readingObject



1074
1075
1076
1077
1078
1079
1080
1081
1082
# File 'lib/activefacts/vocabulary/extensions.rb', line 1074

def all_reading
  @readings ||=
    [ ImplicitReading.new(
        self,
        implying_role.fact_type.entity_type ? "{0} involves {1}" : implying_role.fact_type.default_reading+" Boolean"
      )
    ] +
    Array(implying_role.fact_type.entity_type ? ImplicitReading.new(self, "{1} is involved in {0}") : nil)
end

#default_readingObject



1059
1060
1061
1062
1063
1064
1065
1066
1067
# File 'lib/activefacts/vocabulary/extensions.rb', line 1059

def default_reading
  # There are two cases, where role is in a unary fact type, and where the fact type is objectified
  # If a unary fact type is objectified, only the LinkFactType for the objectification is asserted
  if objectification = implying_role.fact_type.entity_type
    "#{objectification.name} involves #{implying_role.object_type.name}"
  else
    implying_role.fact_type.default_reading+" Boolean"  # Must be a unary FT
  end
end

#reading_preferably_starting_with_role(role, negated = false) ⇒ Object



1084
1085
1086
# File 'lib/activefacts/vocabulary/extensions.rb', line 1084

def reading_preferably_starting_with_role role, negated = false
  all_reading[role == implying_role ? 1 : 0]
end