Skip to content

Commit

Permalink
Merge pull request #4009 from pangratz/consistent-references-methods
Browse files Browse the repository at this point in the history
[FEATURE ds-references] More conistency for RecordReference
  • Loading branch information
bmac committed Dec 17, 2015
2 parents e42d919 + 34a245c commit 8a2af8f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
13 changes: 10 additions & 3 deletions addon/-private/system/references/record.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,21 @@ import Reference from './reference';
var RecordReference = function(store, internalModel) {
this._super$constructor(store, internalModel);
this.type = internalModel.modelName;
this.id = internalModel.id;
this.remoteType = 'identity';
this._id = internalModel.id;
};

RecordReference.prototype = Object.create(Reference.prototype);
RecordReference.prototype.constructor = RecordReference;
RecordReference.prototype._super$constructor = Reference;

RecordReference.prototype.id = function() {
return this._id;
};

RecordReference.prototype.remoteType = function() {
return 'identity';
};

RecordReference.prototype.push = function(objectOrPromise) {
return Ember.RSVP.resolve(objectOrPromise).then((data) => {
var record = this.store.push(data);
Expand All @@ -24,7 +31,7 @@ RecordReference.prototype.value = function() {
};

RecordReference.prototype.load = function() {
return this.store.findRecord(this.type, this.id);
return this.store.findRecord(this.type, this._id);
};

RecordReference.prototype.reload = function() {
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/references/record-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ if (isEnabled("ds-references")) {
test("a RecordReference can be retrieved via store.getReference(type, id)", function(assert) {
var recordReference = env.store.getReference('person', 1);

assert.equal(recordReference.remoteType, 'identity');
assert.equal(recordReference.remoteType(), 'identity');
assert.equal(recordReference.type, 'person');
assert.equal(recordReference.id, 1);
assert.equal(recordReference.id(), 1);
});

test("push(object)", function(assert) {
Expand Down

0 comments on commit 8a2af8f

Please sign in to comment.