Rails-style polymorphic relations

All relations are supported: hasOne, belongsTo, hasMany + through, hasAndBelongsToMany + through. 

Note that explicit through-models are needed, since the intermediate model cannot be created automatically - it's being shared with different models.

Inverse relations are supported as well, and the right model type will be returned.

See also: http://guides.rubyonrails.org/association_basics.html#polymorphic-associations

Examples:

``` javascript
// belongsTo (main polymorphic model)
Picture.belongsTo('imageable', { polymorphic: true });

// hasOne
Author.hasOne(Picture, { as: 'avatar', polymorphic: 'imageable' });
Reader.hasOne(Picture, { as: 'mugshot', polymorphic: 'imageable' });

// hasMany
Author.hasMany(Picture, { polymorphic: 'imageable' });
Reader.hasMany(Picture, { polymorphic: 'imageable' });
      
// hasAndBelongsToMany + through (will setup Picture.belongsTo)
Author.hasAndBelongsToMany(Picture, { through: PictureLink, polymorphic: 'imageable' });
Reader.hasAndBelongsToMany(Picture, { through: PictureLink, polymorphic: 'imageable' });
```





+1.