Skip to content

Commit

Permalink
Use string model names in debug adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
teddyzeenny committed Jun 4, 2015
1 parent f4eefab commit 23d30fd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
15 changes: 10 additions & 5 deletions packages/ember-data/lib/system/debug/debug-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Model from "ember-data/system/model";
var get = Ember.get;
var capitalize = Ember.String.capitalize;
var underscore = Ember.String.underscore;
const { assert } = Ember;

/**
Extend `Ember.DataAdapter` with ED specific code.
Expand Down Expand Up @@ -42,11 +43,15 @@ export default Ember.DataAdapter.extend({
return columns;
},

getRecords: function(modelNameOrFactory) {
// TODO: Ask Teddy what we should do here.
// Ideally this should always get passed a string.

var modelName = typeof modelNameOrFactory === 'string' ? modelNameOrFactory : modelNameOrFactory.modelName;
getRecords: function(klass, modelName) {
if (arguments.length < 2) {
// Legacy Ember.js < 1.13 support
let containerKey = klass._debugContainerKey;
if (containerKey) {
modelName = containerKey.match(/model:(.*)/)[1];
}
}
assert("Cannot find model name. Please upgrade to Ember.js >= 1.13 for Ember Inspector support", !!modelName);
return this.get('store').all(modelName);
},

Expand Down
4 changes: 3 additions & 1 deletion packages/ember-data/tests/integration/debug-adapter-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ module("DS.DebugAdapter", {
App.Post = DS.Model.extend({
title: DS.attr('string')
});

// TODO: Remove this when Ember is upgraded to >= 1.13
App.Post.reopenClass({
modelName: 'post'
_debugContainerKey: 'model:post'
});

});
Expand Down

0 comments on commit 23d30fd

Please sign in to comment.