From ca39ec16114d1ff4ae056fb28accb4f23d4cb4e5 Mon Sep 17 00:00:00 2001 From: Stefan Penner Date: Wed, 26 Apr 2017 13:24:30 -0700 Subject: [PATCH 1/2] Model#willMergeMixin is a development assertion, remove it for prod builds --- addon/-private/system/model/model.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/addon/-private/system/model/model.js b/addon/-private/system/model/model.js index f244a433e26..deb5660181f 100644 --- a/addon/-private/system/model/model.js +++ b/addon/-private/system/model/model.js @@ -842,14 +842,6 @@ const Model = Ember.Object.extend(Ember.Evented, { this._super(...arguments); }, - // This is a temporary solution until we refactor DS.Model to not - // rely on the data property. - willMergeMixin(props) { - let constructor = this.constructor; - assert('`' + intersection(Object.keys(props), RESERVED_MODEL_PROPS)[0] + '` is a reserved property name on DS.Model objects. Please choose a different property name for ' + constructor.toString(), !intersection(Object.keys(props), RESERVED_MODEL_PROPS)[0]); - assert("You may not set `id` as an attribute on your model. Please remove any lines that look like: `id: DS.attr('')` from " + constructor.toString(), Object.keys(props).indexOf('id') === -1); - }, - attr() { assert("The `attr` method is not available on DS.Model, a DS.Snapshot was probably expected. Are you passing a DS.Model instead of a DS.Snapshot to your serializer?", false); }, From ea2682f69a65e22d3ca0fa644664ffd9e58d9a45 Mon Sep 17 00:00:00 2001 From: Stefan Penner Date: Wed, 26 Apr 2017 13:24:39 -0700 Subject: [PATCH 2/2] tidy up spacing --- addon/-private/system/model/model.js | 50 ++++++++++++++++------------ 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/addon/-private/system/model/model.js b/addon/-private/system/model/model.js index deb5660181f..e52b14b8a7d 100644 --- a/addon/-private/system/model/model.js +++ b/addon/-private/system/model/model.js @@ -1877,32 +1877,40 @@ if (isEnabled('ds-rollback-attribute')) { runInDebug(() => { Model.reopen({ - /** - This Ember.js hook allows an object to be notified when a property - is defined. + // This is a temporary solution until we refactor DS.Model to not + // rely on the data property. + willMergeMixin(props) { + let constructor = this.constructor; + assert('`' + intersection(Object.keys(props), RESERVED_MODEL_PROPS)[0] + '` is a reserved property name on DS.Model objects. Please choose a different property name for ' + constructor.toString(), !intersection(Object.keys(props), RESERVED_MODEL_PROPS)[0]); + assert("You may not set `id` as an attribute on your model. Please remove any lines that look like: `id: DS.attr('')` from " + constructor.toString(), Object.keys(props).indexOf('id') === -1); + }, - In this case, we use it to be notified when an Ember Data user defines a - belongs-to relationship. In that case, we need to set up observers for - each one, allowing us to track relationship changes and automatically - reflect changes in the inverse has-many array. + /** + This Ember.js hook allows an object to be notified when a property + is defined. - This hook passes the class being set up, as well as the key and value - being defined. So, for example, when the user does this: + In this case, we use it to be notified when an Ember Data user defines a + belongs-to relationship. In that case, we need to set up observers for + each one, allowing us to track relationship changes and automatically + reflect changes in the inverse has-many array. - ```javascript - DS.Model.extend({ - parent: DS.belongsTo('user') - }); - ``` + This hook passes the class being set up, as well as the key and value + being defined. So, for example, when the user does this: - This hook would be called with "parent" as the key and the computed - property returned by `DS.belongsTo` as the value. + ```javascript + DS.Model.extend({ + parent: DS.belongsTo('user') + }); + ``` - @method didDefineProperty - @param {Object} proto - @param {String} key - @param {Ember.ComputedProperty} value - */ + This hook would be called with "parent" as the key and the computed + property returned by `DS.belongsTo` as the value. + + @method didDefineProperty + @param {Object} proto + @param {String} key + @param {Ember.ComputedProperty} value + */ didDefineProperty(proto, key, value) { // Check if the value being set is a computed property. if (value instanceof Ember.ComputedProperty) {