Skip to content

Commit

Permalink
release v0.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
erikdonohoo committed Dec 20, 2014
1 parent 20f6ef9 commit 047b7ff
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "resourcify",
"version": "0.6.0",
"version": "0.7.0",
"authors": [
"Erik Donohoo <[email protected]>"
],
Expand Down
17 changes: 13 additions & 4 deletions dist/resourcify.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,17 +298,26 @@ function resourcificator ($http, $q, utils, Cache) {
// Before fn
(config.before || angular.noop).apply(value);

// Strip $ from value for data
var sendData = {};
angular.forEach(value, function (v, key) {
if (value.hasOwnProperty(key) && key.charAt(0) !== '$') {
sendData[key] = v;
}
});

var classConfig = config.$Const.$$builder.config.httpConfig;
httpConfig.data = /^(POST|PUT|PATCH|DELETE)$/i.test(config.method) ? value : undefined;
httpConfig.data = /^(POST|PUT|PATCH|DELETE)$/i.test(config.method) ? sendData : undefined;
$http(utils.extendDeep({}, classConfig, config.config || {}, httpConfig)).then(function ok(response) {
if ((config.isArray && !angular.isArray(response.data)) || (!config.isArray && angular.isArray(response.data))) {
var dataToUse = config.propName ? response.data[config.propName] : response.data;
if ((config.isArray && !angular.isArray(dataToUse)) || (!config.isArray && angular.isArray(dataToUse))) {
throw new Error('Saw array or object when expecting the opposite when making ' + config.method +
' call to ' + url);
}

// Build item and handle cache
if (config.isArray) {
angular.forEach(response.data, function (item) {
angular.forEach(dataToUse, function (item) {
var model = typeof item === 'object' ? (Maybe.prototype instanceof config.$Const ?
new Maybe(item) : new config.$Const(item)) : {data: item};
model.$invalid = (config.invalidateListModels && cache);
Expand All @@ -318,7 +327,7 @@ function resourcificator ($http, $q, utils, Cache) {
value = cache.addList(url, value);
}
} else {
value = (typeof response.data === 'object') ? angular.extend(value, response.data) : angular.extend(value, {data: response.data});
value = (typeof dataToUse === 'object') ? angular.extend(value, dataToUse) : angular.extend(value, {data: dataToUse});
if (cache && !config.noCache) {
value = cache.add(value, (config.method === cache.$options.saveMethod));
}
Expand Down
4 changes: 2 additions & 2 deletions dist/resourcify.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "resourcify",
"version": "0.6.0",
"version": "0.7.0",
"description": "Dead simple rich data models for angular",
"main": "Gruntfile.js",
"scripts": {
Expand Down

0 comments on commit 047b7ff

Please sign in to comment.