emberjs/ember.js — pull request #2708 by robharper (2013-05-21 16:58:14+00:00)
Title: Adds set (array) injection capability to Ember.Container

I often find myself adding support for pluggable modules in my Ember apps: the application can be provided [0..N] modules that expose a common interface. For example, a set of "Sharing" plugins that cause a list of provider-specific share buttons to appear within the app with implementations for:

* Facebook
* Pinterest
* Twitter
* LinkedIn
* Email
* etc

Dependency injection is a perfect match for handling this case but at the moment the Ember Container does not support a way to inject a collection of modules into a property as a set (array).

This PR adds support for controlling how objects are injected during instantiation within the container. Specifically, it adds an `options` hash to the `injection` and `typeInjection` functions. The only supported option (other than no options) is `array:true` which causes thus-marked injections to be combined into an array of values. For example:

container.injection('model:sharing', 'plugins', 'plugin:one', {array:true});
container.injection('model:sharing', 'plugins', 'plugin:two', {array:true});

var model = container.lookup('model:sharing');
model.get('plugins').length === 2; // true

Also, added documentation to `injection` and `typeInjection`.