Permalink
Browse files

Use `toString` if environment doesn't support `JSON.stringify`

  • Loading branch information...
1 parent 5546806 commit a21bd0254259d5fc967947cd15faaf59c6a398c7 @tricknotes tricknotes committed Mar 14, 2013
Showing with 3 additions and 2 deletions.
  1. +3 −2 packages/ember-data/lib/adapters/fixture_adapter.js
@@ -2,7 +2,8 @@ require("ember-data/core");
require("ember-data/system/adapter");
require('ember-data/serializers/fixture_serializer');
-var get = Ember.get, fmt = Ember.String.fmt;
+var get = Ember.get, fmt = Ember.String.fmt,
+ dump = Ember.get(window, 'JSON.stringify') || function(object) { return object.toString(); };
/**
`DS.FixtureAdapter` is an adapter that loads records from memory.
@@ -30,7 +31,7 @@ DS.FixtureAdapter = DS.Adapter.extend({
var fixtures = Ember.A(type.FIXTURES);
return fixtures.map(function(fixture){
if(!fixture.id){
- throw new Error(fmt('the id property must be defined for fixture %@', [JSON.stringify(fixture)]));
+ throw new Error(fmt('the id property must be defined for fixture %@', [dump(fixture)]));
}
fixture.id = fixture.id + '';
return fixture;

0 comments on commit a21bd02

Please sign in to comment.