Skip to content

Instantly share code, notes, and snippets.

@bcardarella
Created January 31, 2014 01:03
Show Gist options
  • Save bcardarella/8724725 to your computer and use it in GitHub Desktop.
Save bcardarella/8724725 to your computer and use it in GitHub Desktop.
getModelTypes: function() {
var namespaces = Ember.A(Ember.Namespace.NAMESPACES), types = Ember.A(), self = this;
Object.keys(window.require._eak_seen).reduce(function(previous, item, index, enumerable) {
var match;
if ((match = item.match(/app\/models\/(\w+)/)) && match[1]) {
previous.push(self.get('container').lookupFactory('model:' + match[1]));
}
return previous;
}, types);
namespaces.forEach(function(namespace) {
for (var key in namespace) {
if (!namespace.hasOwnProperty(key)) { continue; }
var klass = namespace[key];
if (self.detect(klass)) {
types.push(klass);
}
}
});
return types;
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment