lib/ripple/conflict/basic_resolver.rb in ripple-1.0.0.beta vs lib/ripple/conflict/basic_resolver.rb in ripple-1.0.0.beta2
- old
+ new
@@ -26,10 +26,14 @@
process_stored_key_associations
end
private
+ def undeleted_siblings
+ @undeleted_siblings ||= siblings.reject(&:deleted?)
+ end
+
def process_properties
model_class.properties.each do |name, property|
document.send(:"#{name}=", resolved_property_value_for(property))
end
end
@@ -51,11 +55,11 @@
document.send(assoc.name).reset_owner_keys if (assoc.type == :many)
end
end
def resolved_property_value_for(property)
- uniq_values = siblings.map(&property.key).uniq
+ uniq_values = undeleted_siblings.map(&property.key).uniq
value = if uniq_values.size == 1
uniq_values.first
elsif property.key == :updated_at
uniq_values.compact.max
@@ -67,10 +71,10 @@
end
end
def resolved_association_value_for(association, proxy_value_method)
# the association proxy doesn't uniquify well, so we have to use the target or links directly
- uniq_values = siblings.map { |s| s.send(association.name).__send__(proxy_value_method) }.uniq
+ uniq_values = undeleted_siblings.map { |s| s.send(association.name).__send__(proxy_value_method) }.uniq
return uniq_values.first if uniq_values.size == 1
remaining_conflicts << association.name
association.many? ? [] : nil # default value