lib/activefacts/api/instance.rb in activefacts-api-1.9.10 vs lib/activefacts/api/instance.rb in activefacts-api-1.9.11
- old
+ new
@@ -75,18 +75,18 @@
# Now, for all roles (from this class and all supertypes), assign nil to all functional roles
# The counterpart roles get cleared automatically.
klasses = [self.class]+self.class.supertypes_transitive
- irvrvs = {} # identifying_role_values by RoleValues
+ key_by_type = {}
self.class.all_role_transitive.each do |_, role|
next unless role.counterpart and
role.unique and
!role.counterpart.unique and
counterpart = send(role.getter)
role_values = counterpart.send(role.counterpart.getter)
- irvrvs[role_values] = role_values.index_values(self)
+ key_by_type[role.object_type] ||= identifying_role_values(role.object_type)
end
# Nullify the counterpart role of objects we identify first, before damaging our identifying_role_values:
klasses.each do |klass|
klass.all_role.each do |role_name, role|
@@ -122,10 +122,10 @@
if (counterpart.unique)
# REVISIT: This will incorrectly fail to propagate a key change for a non-mandatory role
counterpart_instance.send(counterpart.setter, nil, false)
else
rv = counterpart_instance.send(role.counterpart.getter)
- rv.delete_instance(self, irvrvs[rv])
+ rv.delete_instance(self, key_by_type[role.object_type])
if (rv.empty? && !counterpart_instance.class.is_entity_type)
counterpart_instance.retract if counterpart_instance.plays_no_role
end