lib/activefacts/vocabulary/extensions.rb in activefacts-0.7.2 vs lib/activefacts/vocabulary/extensions.rb in activefacts-0.7.3
- old
+ new
@@ -86,11 +86,11 @@
return joiner ? Array(name_array)*joiner : Array(name_array)
end
# Two RoleRefs are equal if they have the same role and Joins with matching roles
def ==(role_ref)
- RoleRef === role_ref &&
+ role_ref.is_a?(ActiveFacts::Metamodel::RoleRef) &&
role_ref.role == role &&
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|
@@ -117,11 +117,10 @@
all_value_type_as_supertype
end
end
class EntityType
- include ActiveFacts
def preferred_identifier
if fact_type
# For a nested fact type, the PI is a unique constraint over N or N-1 roles
fact_roles = Array(fact_type.all_role)
@@ -159,11 +158,11 @@
}
throw :pi, nil
end
debug :pi, "Got PI #{pi.name||pi.object_id} for nested #{name}" if pi
debug :pi, "Looking for PI on entity that nests this fact" unless pi
- raise "Oops, pi for nested fact is #{pi.class}" unless !pi || PresenceConstraint === pi
+ raise "Oops, pi for nested fact is #{pi.class}" unless !pi || pi.is_a?(ActiveFacts::Metamodel::PresenceConstraint)
return pi if pi
end
end
debug :pi, "Looking for PI for ordinary entity #{name} with #{all_role.size} roles:" do
@@ -226,11 +225,11 @@
}
}
}
throw :pi, nil
end
- raise "Oops, pi for entity is #{pi.class}" if pi && !(PresenceConstraint === pi)
+ raise "Oops, pi for entity is #{pi.class}" if pi && !pi.is_a?(ActiveFacts::Metamodel::PresenceConstraint)
debug :pi, "Got PI #{pi.name||pi.object_id} for #{name}" if pi
if !pi
if (supertype = identifying_supertype)
# This shouldn't happen now, as an identifying supertype is connected by a fact type
@@ -330,11 +329,11 @@
role_name = nil if role_name == ""
if role_name && define_role_names == false
la = ta = nil # When using role names, don't add adjectives
end
fc = frequency_constraints[i]
- fc = fc.frequency if fc && PresenceConstraint === fc
- if Array === fc
+ fc = fc.frequency if fc && fc.is_a?(ActiveFacts::Metamodel::PresenceConstraint)
+ if fc.is_a?(Array)
fc, player_name = *fc
else
player_name = player.name
end
[