emberjs/ember.js — pull request #1442 by endash (2012-10-10 02:47:48+00:00)
Title: Don't attempt to concat a concatenatedProperty onto an object that doesn...

...'t have a concat method

Try in any console:

Ember.Object.extend({foo: 1}, {concatenatedProperties:['foo'], foo: 2}).create();
=> TypeError: Object 1 has no method 'concat'

alternatively:
Ember.Object.extend({foobar: 'foo'}, {concatenatedProperties:['foobar'], foobar: 'bar'}).create().get('foobar');
=> "foobar"

If a previous value exists, #concat is blindly called on it assuming it is an array. I was previously taking advantage of this by creating a custom class that enables concatenating properties, and defining it on an anonymous mixin prior to my real mixin. Then, instead of wrapping my objects in an array, they got concatenated onto my root, custom object.

This is obviously a bug. How it is resolved is something of an open question. I would prefer a permissive solution, as I have implemented, which allows a pre-existing property the chance to handle the concatenation itself, otherwise the value gets wrapped into an array. The restrictive solution would be simply to check to see if the pre-existing property is an array and concat if it is, or wrap it in an array and then concat if it is not.