Skip to content

Commit

Permalink
Replace deprecated ember_assert with Ember.assert
Browse files Browse the repository at this point in the history
This fixes all instances of the old un-namespaced ember_* functions.
  • Loading branch information
joliss committed May 6, 2012
1 parent 9a070be commit b4a415e
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions packages/ember-data/lib/adapters/fixture_adapter.js
Expand Up @@ -5,7 +5,7 @@ DS.fixtureAdapter = DS.Adapter.create({
find: function(store, type, id) {
var fixtures = type.FIXTURES;

ember_assert("Unable to find fixtures for model type "+type.toString(), !!fixtures);
Ember.assert("Unable to find fixtures for model type "+type.toString(), !!fixtures);
if (fixtures.hasLoaded) { return; }

setTimeout(function() {
Expand All @@ -21,7 +21,7 @@ DS.fixtureAdapter = DS.Adapter.create({
findAll: function(store, type) {
var fixtures = type.FIXTURES;

ember_assert("Unable to find fixtures for model type "+type.toString(), !!fixtures);
Ember.assert("Unable to find fixtures for model type "+type.toString(), !!fixtures);

var ids = fixtures.map(function(item, index, self){ return item.id; });
store.loadMany(type, ids, fixtures);
Expand Down
10 changes: 5 additions & 5 deletions packages/ember-data/lib/adapters/rest_adapter.js
Expand Up @@ -207,10 +207,10 @@ DS.RESTAdapter = DS.Adapter.extend({

if (!sideloadedType) {
mappings = get(this, 'mappings');
ember_assert("Your server returned a hash with the key " + prop + " but you have no mappings", !!mappings);
Ember.assert("Your server returned a hash with the key " + prop + " but you have no mappings", !!mappings);

sideloadedType = get(mappings, prop);
ember_assert("Your server returned a hash with the key " + prop + " but you have no mapping for it", !!sideloadedType);
Ember.assert("Your server returned a hash with the key " + prop + " but you have no mapping for it", !!sideloadedType);
}

this.loadValue(store, sideloadedType, json[prop]);
Expand All @@ -228,9 +228,9 @@ DS.RESTAdapter = DS.Adapter.extend({
buildURL: function(record, suffix) {
var url = [""];

ember_assert("Namespace URL (" + this.namespace + ") must not start with slash", !this.namespace || this.namespace.toString().charAt(0) !== "/");
ember_assert("Record URL (" + record + ") must not start with slash", !record || record.toString().charAt(0) !== "/");
ember_assert("URL suffix (" + suffix + ") must not start with slash", !suffix || suffix.toString().charAt(0) !== "/");
Ember.assert("Namespace URL (" + this.namespace + ") must not start with slash", !this.namespace || this.namespace.toString().charAt(0) !== "/");
Ember.assert("Record URL (" + record + ") must not start with slash", !record || record.toString().charAt(0) !== "/");
Ember.assert("URL suffix (" + suffix + ") must not start with slash", !suffix || suffix.toString().charAt(0) !== "/");

if (this.namespace !== undefined) {
url.push(this.namespace);
Expand Down
2 changes: 1 addition & 1 deletion packages/ember-data/lib/system/associations/belongs_to.js
Expand Up @@ -52,6 +52,6 @@ var hasAssociation = function(type, options, one) {
};

DS.belongsTo = function(type, options) {
ember_assert("The type passed to DS.belongsTo must be defined", !!type);
Ember.assert("The type passed to DS.belongsTo must be defined", !!type);
return hasAssociation(type, options);
};
2 changes: 1 addition & 1 deletion packages/ember-data/lib/system/associations/has_many.js
Expand Up @@ -38,6 +38,6 @@ var hasAssociation = function(type, options) {
};

DS.hasMany = function(type, options) {
ember_assert("The type passed to DS.hasMany must be defined", !!type);
Ember.assert("The type passed to DS.hasMany must be defined", !!type);
return hasAssociation(type, options);
};
2 changes: 1 addition & 1 deletion packages/ember-data/lib/system/model/attributes.js
Expand Up @@ -28,7 +28,7 @@ DS.Model.reopenClass({

DS.attr = function(type, options) {
var transform = DS.attr.transforms[type];
ember_assert("Could not find model attribute of type " + type, !!transform);
Ember.assert("Could not find model attribute of type " + type, !!transform);

var transformFrom = transform.from;
var transformTo = transform.to;
Expand Down
4 changes: 2 additions & 2 deletions packages/ember-data/lib/system/model/model.js
Expand Up @@ -250,15 +250,15 @@ DS.Model = Ember.Object.extend(Ember.Evented, {
var data = get(this, 'data');

if (data && key in data) {
ember_assert("You attempted to access the " + key + " property on a record without defining an attribute.", false);
Ember.assert("You attempted to access the " + key + " property on a record without defining an attribute.", false);
}
},

setUnknownProperty: function(key, value) {
var data = get(this, 'data');

if (data && key in data) {
ember_assert("You attempted to set the " + key + " property on a record without defining an attribute.", false);
Ember.assert("You attempted to set the " + key + " property on a record without defining an attribute.", false);
} else {
return this._super(key, value);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/ember-data/lib/system/record_array/many_array.js
Expand Up @@ -35,7 +35,7 @@ DS.ManyArray = DS.RecordArray.extend({
var stateManager = get(this, 'stateManager');

added = added.map(function(record) {
ember_assert("You can only add records of " + (get(this, 'type') && get(this, 'type').toString()) + " to this association.", !get(this, 'type') || (get(this, 'type') === record.constructor));
Ember.assert("You can only add records of " + (get(this, 'type') && get(this, 'type').toString()) + " to this association.", !get(this, 'type') || (get(this, 'type') === record.constructor));

if (pendingParent) {
record.send('waitingOn', parentRecord);
Expand Down
8 changes: 4 additions & 4 deletions packages/ember-data/lib/system/store.js
Expand Up @@ -573,11 +573,11 @@ DS.Store = Ember.Object.extend({

primaryKey = type.proto().primaryKey;

// TODO: Make ember_assert more flexible and convert this into an ember_assert
// TODO: Make Ember.assert more flexible and convert this into an Ember.assert
if (hash) {
ember_assert("The server must provide a primary key: " + primaryKey, get(hash, primaryKey));
Ember.assert("The server must provide a primary key: " + primaryKey, get(hash, primaryKey));
} else {
ember_assert("The server did not return data, and you did not create a primary key (" + primaryKey + ") on the client", get(get(record, 'data'), primaryKey));
Ember.assert("The server did not return data, and you did not create a primary key (" + primaryKey + ") on the client", get(get(record, 'data'), primaryKey));
}

clientId = get(record, 'clientId');
Expand Down Expand Up @@ -750,7 +750,7 @@ DS.Store = Ember.Object.extend({
if (hash === undefined) {
hash = id;
var primaryKey = type.proto().primaryKey;
ember_assert("A data hash was loaded for a record of type " + type.toString() + " but no primary key '" + primaryKey + "' was provided.", primaryKey in hash);
Ember.assert("A data hash was loaded for a record of type " + type.toString() + " but no primary key '" + primaryKey + "' was provided.", primaryKey in hash);
id = hash[primaryKey];
}

Expand Down
4 changes: 2 additions & 2 deletions packages/ember-data/lib/system/transaction.js
Expand Up @@ -120,12 +120,12 @@ DS.Transaction = Ember.Object.extend({
*/
add: function(record) {
// we could probably make this work if someone has a valid use case. Do you?
ember_assert("Once a record has changed, you cannot move it into a different transaction", !get(record, 'isDirty'));
Ember.assert("Once a record has changed, you cannot move it into a different transaction", !get(record, 'isDirty'));

var recordTransaction = get(record, 'transaction'),
defaultTransaction = getPath(this, 'store.defaultTransaction');

ember_assert("Models cannot belong to more than one transaction at a time.", recordTransaction === defaultTransaction);
Ember.assert("Models cannot belong to more than one transaction at a time.", recordTransaction === defaultTransaction);

this.adoptRecord(record);
},
Expand Down

0 comments on commit b4a415e

Please sign in to comment.