Skip to content

Commit

Permalink
Merge pull request #4948 from emberjs/only-will-merge-mixin-in-dev
Browse files Browse the repository at this point in the history
Only will merge mixin in dev
  • Loading branch information
stefanpenner authored Apr 26, 2017
2 parents 05e9528 + ea2682f commit 35e014b
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions addon/-private/system/model/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('<type>')` 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);
},
Expand Down Expand Up @@ -1885,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('<type>')` 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:
```javascript
DS.Model.extend({
parent: DS.belongsTo('user')
});
```
This hook would be called with "parent" as the key and the computed
property returned by `DS.belongsTo` as the 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
*/
@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) {
Expand Down

0 comments on commit 35e014b

Please sign in to comment.