diff --git a/addon/-private/system/model/internal-model.js b/addon/-private/system/model/internal-model.js index b3c683b2ca9..e05057a1fee 100644 --- a/addon/-private/system/model/internal-model.js +++ b/addon/-private/system/model/internal-model.js @@ -5,7 +5,6 @@ import RootState from "ember-data/-private/system/model/states"; import Relationships from "ember-data/-private/system/relationships/state/create"; import Snapshot from "ember-data/-private/system/snapshot"; import EmptyObject from "ember-data/-private/system/empty-object"; -import isEnabled from 'ember-data/-private/features'; import { getOwner @@ -243,16 +242,8 @@ InternalModel.prototype = { @method createSnapshot @private */ - createSnapshot(options = {}) { - const snapshot = new Snapshot(this); - - snapshot.adapterOptions = options.adapterOptions; - - if (isEnabled('ds-finder-include')) { - snapshot.include = options.include; - } - - return snapshot; + createSnapshot(options) { + return new Snapshot(this, options); }, /** diff --git a/addon/-private/system/record-arrays/record-array.js b/addon/-private/system/record-arrays/record-array.js index 33c8f3f8f73..a34aa397d62 100644 --- a/addon/-private/system/record-arrays/record-array.js +++ b/addon/-private/system/record-arrays/record-array.js @@ -5,7 +5,6 @@ import Ember from 'ember'; import { PromiseArray } from "ember-data/-private/system/promise-proxies"; import SnapshotRecordArray from "ember-data/-private/system/snapshot-record-array"; -import isEnabled from 'ember-data/-private/features'; var get = Ember.get; var set = Ember.set; @@ -202,16 +201,8 @@ export default Ember.ArrayProxy.extend(Ember.Evented, { this._super.apply(this, arguments); }, - createSnapshot(options = {}) { - const adapterOptions = options.adapterOptions; + createSnapshot(options) { const meta = this.get('meta'); - - const snapshot = new SnapshotRecordArray(this, meta, adapterOptions); - - if (isEnabled('ds-finder-include')) { - snapshot.include = options.include; - } - - return snapshot; + return new SnapshotRecordArray(this, meta, options); } }); diff --git a/addon/-private/system/snapshot-record-array.js b/addon/-private/system/snapshot-record-array.js index 130cde032c2..a7ccfa8c13d 100644 --- a/addon/-private/system/snapshot-record-array.js +++ b/addon/-private/system/snapshot-record-array.js @@ -2,6 +2,8 @@ @module ember-data */ +import isEnabled from 'ember-data/-private/features'; + /** @class SnapshotRecordArray @namespace DS @@ -10,7 +12,7 @@ @param {Array} snapshots An array of snapshots @param {Object} meta */ -export default function SnapshotRecordArray(recordArray, meta, adapterOptions) { +export default function SnapshotRecordArray(recordArray, meta, options = {}) { /** An array of snapshots @private @@ -48,7 +50,11 @@ export default function SnapshotRecordArray(recordArray, meta, adapterOptions) { @property adapterOptions @type {Object} */ - this.adapterOptions = adapterOptions; + this.adapterOptions = options.adapterOptions; + + if (isEnabled('ds-finder-include')) { + this.include = options.include; + } } /** diff --git a/addon/-private/system/snapshot.js b/addon/-private/system/snapshot.js index c7f23c9e29f..e594b4dd252 100644 --- a/addon/-private/system/snapshot.js +++ b/addon/-private/system/snapshot.js @@ -4,6 +4,8 @@ import Ember from 'ember'; import EmptyObject from "ember-data/-private/system/empty-object"; +import isEnabled from 'ember-data/-private/features'; + var get = Ember.get; /** @@ -13,7 +15,7 @@ var get = Ember.get; @constructor @param {DS.Model} internalModel The model to create a snapshot from */ -export default function Snapshot(internalModel) { +export default function Snapshot(internalModel, options = {}) { this._attributes = new EmptyObject(); this._belongsToRelationships = new EmptyObject(); this._belongsToIds = new EmptyObject(); @@ -29,6 +31,17 @@ export default function Snapshot(internalModel) { this.type = internalModel.type; this.modelName = internalModel.type.modelName; + /** + A hash of adapter options + @property adapterOptions + @type {Object} + */ + this.adapterOptions = options.adapterOptions; + + if (isEnabled('ds-finder-include')) { + this.include = options.include; + } + this._changedAttributes = record.changedAttributes(); }