}).then(function(newData) { if ( !newData || !Type.detect(newData) ) { return newData; } var newId = newData.get('id'); var newType = normalizeType(newData.get('type')); if ( !id && newId && type === newType ) { Ember.beginPropertyChanges(); // A new record was created. Typeify will have put it into the store, // but it's not the same instance as this object. So we need to fix that. self.merge(newData); var existing = store.getById(type,newId); if ( existing ) { store._remove(type, existing); } store._add(type, self); Ember.endPropertyChanges(); } return self; });
_notifyProperties: function _notifyProperties(keys) { Ember.beginPropertyChanges(); var key; for (var i = 0, length = keys.length; i < length; i++) { key = keys[i]; this.notifyPropertyChange(key); } Ember.endPropertyChanges(); },
deselectObjects: function() { var item, items, _i, _len; items = 1 <= arguments.length ? __slice.call(arguments, 0) : []; items = [].concat.apply([], items); Ember.beginPropertyChanges(this); for (_i = 0, _len = items.length; _i < _len; _i++) { item = items[_i]; this.deselectObject(item); } Ember.endPropertyChanges(this); return this; },
select: function(item, options) { var end, indexOfCursor, range, retainSelection, selectionRange, start, targetIdx, toggle, _i, _results; options = options != null ? options : {}; if (typeOf(item) === 'number') { item = this.objectAt(parseInt(item, 10)); } toggle = get(options, 'toggle'); range = get(options, 'range'); retainSelection = get(options, 'retainSelection'); if (toggle || range) { if (toggle) { if (this.inSelection(item)) { this.deselectObject(item); } else { this.selectObject(item); } } else if (range) { targetIdx = +this.indexOf(item); indexOfCursor = this.indexOfCursor(); start = Math.min(targetIdx, indexOfCursor); end = Math.max(targetIdx, indexOfCursor); selectionRange = (function() { _results = []; for (var _i = start; start <= end ? _i <= end : _i >= end; start <= end ? _i++ : _i--){ _results.push(_i); } return _results; }).apply(this); this.selectObjects(selectionRange); } } else { Ember.beginPropertyChanges(this); if (!retainSelection) { this.deselectAll(); } this.selectObject(item); Ember.endPropertyChanges(this); } return this; },
if (this.isDestroyed) { return; } this._internalModel.unloadRecord(); }, /** @method _notifyProperties @private */ _notifyProperties(keys) { Ember.beginPropertyChanges(); var key; for (var i = 0, length = keys.length; i < length; i++) { key = keys[i]; this.notifyPropertyChange(key); } Ember.endPropertyChanges(); }, /** Returns an object, whose keys are changed properties, and value is an [oldProp, newProp] array. The array represents the diff of the canonical state with the local state of the model. Note: if the model is created locally, the canonical state is empty since the adapter hasn't acknowledged the attributes yet: Example ```app/models/mascot.js import DS from 'ember-data';