Skip to content

Commit

Permalink
Fixes #235.
Browse files Browse the repository at this point in the history
Stable Version 1.4.0.
  • Loading branch information
jmdobry committed Nov 9, 2014
1 parent ad29d65 commit 8717141
Show file tree
Hide file tree
Showing 13 changed files with 95 additions and 66 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
##### 1.4.0 - 09 November 2014

###### Backwards compatible API changes
- #227 - Supporting methods on model instances (again)

###### Backwards compatible bug fixes
- #234 - Fixed an issue with DSLocalStorageAdapter.update
- #235 - IE 8 support

##### 1.3.0 - 07 November 2014

###### Backwards compatible API changes
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Unlike Backbone and Ember Models, angular-data does not require the use of gette

Supporting relations, computed properties, model lifecycle control and a slew of other features, angular-data is the tool for giving your data the respect it deserves.

__Latest Release:__ [1.3.0](https://github.com/jmdobry/angular-data/releases/tag/1.3.0)
__Latest Release:__ [1.4.0](https://github.com/jmdobry/angular-data/releases/tag/1.4.0)

Angular-data is finally 1.0.!

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"author": "Jason Dobry",
"name": "angular-data",
"description": "Data store for Angular.js.",
"version": "1.3.0",
"version": "1.4.0",
"homepage": "http://angular-data.pseudobry.com/",
"repository": {
"type": "git",
Expand Down
70 changes: 40 additions & 30 deletions dist/angular-data.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @author Jason Dobry <jason.dobry@gmail.com>
* @file angular-data.js
* @version 1.3.0 - Homepage <http://angular-data.pseudobry.com/>
* @version 1.4.0 - Homepage <http://angular-data.pseudobry.com/>
* @copyright (c) 2014 Jason Dobry <https://github.com/jmdobry/>
* @license MIT <https://github.com/jmdobry/angular-data/blob/master/LICENSE>
*
Expand All @@ -26,6 +26,7 @@
// Copyright 2014 Jason Dobry
//
// Summary of modifications:
// Fixed use of "delete" keyword for IE8 compatibility
// Removed all code related to:
// - ArrayObserver
// - ArraySplice
Expand Down Expand Up @@ -523,7 +524,7 @@
var expectedRecordTypes = {
add: true,
update: true,
delete: true
'delete': true
};

function diffObjectFromChangeRecords(object, changeRecords, oldValues) {
Expand Down Expand Up @@ -2826,13 +2827,12 @@ function create(resourceName, attrs, options) {
} else {
return DS.createInstance(resourceName, attrs, options);
}
})
.catch(function (err) {
if (options.eagerInject && options.cacheResponse) {
DS.eject(resourceName, injected[definition.idAttribute], { notify: false });
}
return DS.$q.reject(err);
});
})['catch'](function (err) {
if (options.eagerInject && options.cacheResponse) {
DS.eject(resourceName, injected[definition.idAttribute], { notify: false });
}
return DS.$q.reject(err);
});
}
} catch (err) {
deferred.reject(err);
Expand Down Expand Up @@ -2939,12 +2939,12 @@ function destroy(resourceName, id, options) {
}
DS.eject(resourceName, id);
return id;
}).catch(function (err) {
if (options.eagerEject && item) {
DS.inject(resourceName, item);
}
return DS.$q.reject(err);
});
})['catch'](function (err) {
if (options.eagerEject && item) {
DS.inject(resourceName, item);
}
return DS.$q.reject(err);
});
} catch (err) {
deferred.reject(err);
return deferred.promise;
Expand Down Expand Up @@ -5369,7 +5369,7 @@ function createInstance(resourceName, attrs, options) {
var item;

if (options.useClass) {
var Func = definition[definition.class];
var Func = definition[definition['class']];
item = new Func();
} else {
item = {};
Expand Down Expand Up @@ -5398,7 +5398,17 @@ var instanceMethods = [
'save',
'update',
'destroy',
'refresh'
'refresh',
'loadRelations',
'changeHistory',
'changes',
'hasChanges',
'lastModified',
'lastSaved',
'link',
'linkInverse',
'previous',
'unlinkInverse'
];

var methodsToProxy = [
Expand Down Expand Up @@ -5620,13 +5630,13 @@ function defineResource(definition) {
});

// Create the wrapper class for the new resource
def.class = DSUtils.pascalCase(defName);
eval('function ' + def.class + '() {}');
def[def.class] = eval(def.class);
def['class'] = DSUtils.pascalCase(defName);
eval('function ' + def['class'] + '() {}');
def[def['class']] = eval(def['class']);

// Apply developer-defined methods
if (def.methods) {
DSUtils.deepMixIn(def[def.class].prototype, def.methods);
DSUtils.deepMixIn(def[def['class']].prototype, def.methods);
}

// Prepare for computed properties
Expand Down Expand Up @@ -5658,13 +5668,13 @@ function defineResource(definition) {
});
});

def[def.class].prototype.DSCompute = function () {
def[def['class']].prototype.DSCompute = function () {
return DS.compute(def.name, this);
};
}

DSUtils.forEach(instanceMethods, function (name) {
def[def.class].prototype['DS' + DSUtils.pascalCase(name)] = function () {
def[def['class']].prototype['DS' + DSUtils.pascalCase(name)] = function () {
var args = Array.prototype.slice.call(arguments);
args.unshift(this[def.idAttribute]);
args.unshift(def.name);
Expand Down Expand Up @@ -6581,8 +6591,8 @@ function _inject(definition, resource, attrs, options) {

if (definition.idAttribute in changed) {
$log.error('Doh! You just changed the primary key of an object! ' +
'I don\'t know how to handle this yet, so your data for the "' + definition.name +
'" resource is now in an undefined (probably broken) state.');
'I don\'t know how to handle this yet, so your data for the "' + definition.name +
'" resource is now in an undefined (probably broken) state.');
}
}

Expand Down Expand Up @@ -6616,10 +6626,10 @@ function _inject(definition, resource, attrs, options) {

if (!item) {
if (options.useClass) {
if (attrs instanceof definition[definition.class]) {
if (attrs instanceof definition[definition['class']]) {
item = attrs;
} else {
item = new definition[definition.class]();
item = new definition[definition['class']]();
}
} else {
item = {};
Expand Down Expand Up @@ -7434,7 +7444,7 @@ function IllegalArgumentError(message) {
this.message = message || 'Illegal Argument!';
}

IllegalArgumentError.prototype = Object.create(Error.prototype);
IllegalArgumentError.prototype = new Error();
IllegalArgumentError.prototype.constructor = IllegalArgumentError;

/**
Expand Down Expand Up @@ -7470,7 +7480,7 @@ function RuntimeError(message) {
this.message = message || 'RuntimeError Error!';
}

RuntimeError.prototype = Object.create(Error.prototype);
RuntimeError.prototype = new Error();
RuntimeError.prototype.constructor = RuntimeError;

/**
Expand Down Expand Up @@ -7506,7 +7516,7 @@ function NonexistentResourceError(resourceName) {
this.message = (resourceName || '') + ' is not a registered resource!';
}

NonexistentResourceError.prototype = Object.create(Error.prototype);
NonexistentResourceError.prototype = new Error();
NonexistentResourceError.prototype.constructor = NonexistentResourceError;

/**
Expand Down
8 changes: 4 additions & 4 deletions dist/angular-data.min.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion lib/observe-js/observe-js.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// Copyright 2014 Jason Dobry
//
// Summary of modifications:
// Fixed use of "delete" keyword for IE8 compatibility
// Removed all code related to:
// - ArrayObserver
// - ArraySplice
Expand Down Expand Up @@ -513,7 +514,7 @@
var expectedRecordTypes = {
add: true,
update: true,
delete: true
'delete': true
};

function diffObjectFromChangeRecords(object, changeRecords, oldValues) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "angular-data",
"description": "Data store for Angular.js.",
"version": "1.3.0",
"version": "1.4.0",
"homepage": "http://angular-data.pseudobry.com",
"repository": {
"type": "git",
Expand Down
13 changes: 6 additions & 7 deletions src/datastore/async_methods/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,12 @@ function create(resourceName, attrs, options) {
} else {
return DS.createInstance(resourceName, attrs, options);
}
})
.catch(function (err) {
if (options.eagerInject && options.cacheResponse) {
DS.eject(resourceName, injected[definition.idAttribute], { notify: false });
}
return DS.$q.reject(err);
});
})['catch'](function (err) {
if (options.eagerInject && options.cacheResponse) {
DS.eject(resourceName, injected[definition.idAttribute], { notify: false });
}
return DS.$q.reject(err);
});
}
} catch (err) {
deferred.reject(err);
Expand Down
12 changes: 6 additions & 6 deletions src/datastore/async_methods/destroy.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ function destroy(resourceName, id, options) {
}
DS.eject(resourceName, id);
return id;
}).catch(function (err) {
if (options.eagerEject && item) {
DS.inject(resourceName, item);
}
return DS.$q.reject(err);
});
})['catch'](function (err) {
if (options.eagerEject && item) {
DS.inject(resourceName, item);
}
return DS.$q.reject(err);
});
} catch (err) {
deferred.reject(err);
return deferred.promise;
Expand Down
2 changes: 1 addition & 1 deletion src/datastore/sync_methods/createInstance.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function createInstance(resourceName, attrs, options) {
var item;

if (options.useClass) {
var Func = definition[definition.class];
var Func = definition[definition['class']];
item = new Func();
} else {
item = {};
Expand Down
24 changes: 17 additions & 7 deletions src/datastore/sync_methods/defineResource.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,17 @@ var instanceMethods = [
'save',
'update',
'destroy',
'refresh'
'refresh',
'loadRelations',
'changeHistory',
'changes',
'hasChanges',
'lastModified',
'lastSaved',
'link',
'linkInverse',
'previous',
'unlinkInverse'
];

var methodsToProxy = [
Expand Down Expand Up @@ -238,13 +248,13 @@ function defineResource(definition) {
});

// Create the wrapper class for the new resource
def.class = DSUtils.pascalCase(defName);
eval('function ' + def.class + '() {}');
def[def.class] = eval(def.class);
def['class'] = DSUtils.pascalCase(defName);
eval('function ' + def['class'] + '() {}');
def[def['class']] = eval(def['class']);

// Apply developer-defined methods
if (def.methods) {
DSUtils.deepMixIn(def[def.class].prototype, def.methods);
DSUtils.deepMixIn(def[def['class']].prototype, def.methods);
}

// Prepare for computed properties
Expand Down Expand Up @@ -276,13 +286,13 @@ function defineResource(definition) {
});
});

def[def.class].prototype.DSCompute = function () {
def[def['class']].prototype.DSCompute = function () {
return DS.compute(def.name, this);
};
}

DSUtils.forEach(instanceMethods, function (name) {
def[def.class].prototype['DS' + DSUtils.pascalCase(name)] = function () {
def[def['class']].prototype['DS' + DSUtils.pascalCase(name)] = function () {
var args = Array.prototype.slice.call(arguments);
args.unshift(this[def.idAttribute]);
args.unshift(def.name);
Expand Down
8 changes: 4 additions & 4 deletions src/datastore/sync_methods/inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ function _inject(definition, resource, attrs, options) {

if (definition.idAttribute in changed) {
$log.error('Doh! You just changed the primary key of an object! ' +
'I don\'t know how to handle this yet, so your data for the "' + definition.name +
'" resource is now in an undefined (probably broken) state.');
'I don\'t know how to handle this yet, so your data for the "' + definition.name +
'" resource is now in an undefined (probably broken) state.');
}
}

Expand Down Expand Up @@ -120,10 +120,10 @@ function _inject(definition, resource, attrs, options) {

if (!item) {
if (options.useClass) {
if (attrs instanceof definition[definition.class]) {
if (attrs instanceof definition[definition['class']]) {
item = attrs;
} else {
item = new definition[definition.class]();
item = new definition[definition['class']]();
}
} else {
item = {};
Expand Down
6 changes: 3 additions & 3 deletions src/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function IllegalArgumentError(message) {
this.message = message || 'Illegal Argument!';
}

IllegalArgumentError.prototype = Object.create(Error.prototype);
IllegalArgumentError.prototype = new Error();
IllegalArgumentError.prototype.constructor = IllegalArgumentError;

/**
Expand Down Expand Up @@ -67,7 +67,7 @@ function RuntimeError(message) {
this.message = message || 'RuntimeError Error!';
}

RuntimeError.prototype = Object.create(Error.prototype);
RuntimeError.prototype = new Error();
RuntimeError.prototype.constructor = RuntimeError;

/**
Expand Down Expand Up @@ -103,7 +103,7 @@ function NonexistentResourceError(resourceName) {
this.message = (resourceName || '') + ' is not a registered resource!';
}

NonexistentResourceError.prototype = Object.create(Error.prototype);
NonexistentResourceError.prototype = new Error();
NonexistentResourceError.prototype.constructor = NonexistentResourceError;

/**
Expand Down

0 comments on commit 8717141

Please sign in to comment.