Created
February 7, 2012 19:44
-
-
Save doxavore/1761475 to your computer and use it in GitHub Desktop.
Don't let Ember.js override setter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment