Shopify/batman — pull request #644 by peterjm (2013-02-06 15:00:59+00:00)
Title: Allow customized relation matching

Wouldn't mind some input from @hornairs @jamesmacaulay

This is a work-in-progress; I've tested it manually but it's still in development.

## Problem

After a `save` takes place, if the returned JSON includes an association for which the in-memory Model doesn't have a match (based on `id`), then Batman will arbitrarily choose the first unsaved association to overwrite with the returned JSON. This probably works in most cases, but it can lead to situations where the wrong association is overwritten.

## Solution

The idea is to provide a method to override in subclasses of `PolymorphicHasManyAssociation`, to allow more intelligent matching of the returned JSON to the unsaved relations.

By default, the matcher returns `true`, preserving the current functionality.

## Concerns

Adding a useless method to a class, just to provide a hook to override, is generally a bad smell.