emberjs/ember.js — Issue #476: Passing value to Object#create overrides property setter
Author: doxavore
Created: 2012-02-07 20:00:08+00:00
State: open

I would have expected when I create a subclass of `Ember.Object` and define a property, when I initialize that object with `Person.create({ pets: ["Fido"] })` it would call the setter for pets. However, it sets pets directly to the value, blasting away my getter/setter property.

I'm not sure if this is intentional or not, but it seems like the behavior is wrong. I wouldn't expect a difference in behavior between passing an initialization object to `create` and `setProperties`.

```javascript
Person = Ember.Object.extend({
pets: (function (key, val) {
if (arguments.length > 1) {
// set value
}
else {
// return value
}
}).property('_pets')
});

Person.reopenClass({
create: function (opts) {
var obj, pets;

if (opts && opts.pets) {
pets = opts.pets;
delete opts.pets;
}

obj = this._super.apply(this, arguments);
if (pets) {
obj.set('pets', pets);
}
return obj;
}
});
```