mavenlink/brainstem-js — pull request #34 by jrolfs (2014-07-24 21:33:16+00:00)
Title: Add support for polymorphic "belongs to" associations

Polymorphic associations are described in the `Brainstem.Model@associations` hash as an array of strings representing the key for each possible model type.

- `Brainstem.Model#get` now supports associations returned both as and ID and a "reference"
- A "reference" is an object containing both the model ID and Brainstem collection key, eg: `{ id: 123, key: 'posts' }`
- When `get` is called on a polymorphic belongs to association, the reference key is used to locate the model data from the top level collection hash in the response data
- Existing behavior for retrieving non-polymorphic associations by ID and the defined association collection key is preserved

- `Brainstem.Model@associationsAreLoaded` now supports both ID and "references" for determining whether a given model instance's associations have been loaded and cached