class ActiveFacts::Metamodel::Vocabulary
Public Instance Methods
check_valid_nonexistent_object_type_name(name)
click to toggle source
This name does not yet exist (at least not as we expect it to). If it in fact does exist (but as the wrong type), complain. If it doesn't exist, but its name would cause existing fact type readings to be re-interpreted to a different meaning, complain. Otherwise return nil.
# File lib/activefacts/metamodel/extensions.rb, line 27 def check_valid_nonexistent_object_type_name name if ot = valid_object_type_name(name) raise "Cannot redefine #{ot.class.basename} #{name}" end end
finalise()
click to toggle source
# File lib/activefacts/metamodel/extensions.rb, line 12 def finalise constellation.FactType.values.each do |fact_type| if c = fact_type.check_and_add_spanning_uniqueness_constraint trace :constraint, "Checking for existence of at least one uniqueness constraint over the roles of #{fact_type.default_reading.inspect}" fact_type.check_and_add_spanning_uniqueness_constraint = nil c.call end end end
object_type_lookup(name)
click to toggle source
# File lib/activefacts/metamodel/extensions.rb, line 70 def object_type_lookup name @constellation.ObjectType[[identifying_role_values, name]] end
valid_entity_type_name(name)
click to toggle source
If this entity type exists, ok, otherwise check it's ok to add it
# File lib/activefacts/metamodel/extensions.rb, line 59 def valid_entity_type_name name @constellation.EntityType[[identifying_role_values, name]] or check_valid_nonexistent_object_type_name name end
valid_object_type_name(name)
click to toggle source
# File lib/activefacts/metamodel/extensions.rb, line 33 def valid_object_type_name name # Raise an exception if adding this name to the vocabulary would create anomalies anomaly = constellation.Reading.detect do |r_key, reading| expanded = reading.expand do |role_ref, *words| words.map! do |w| case when w == nil w when w[0...name.size] == name '_ok_'+w when w[-name.size..-1] == name w[-1]+'_ok_' else w end end words end expanded =~ %r{\b#{name}\b} end raise "Adding new term '#{name}' would create anomalous re-interpretation of '#{anomaly.expand}'" if anomaly @constellation.ObjectType[[identifying_role_values, name]] end
valid_value_type_name(name)
click to toggle source
If this entity type exists, ok, otherwise check it's ok to add it
# File lib/activefacts/metamodel/extensions.rb, line 65 def valid_value_type_name name @constellation.ValueType[[identifying_role_values, name]] or check_valid_nonexistent_object_type_name name end