Skip to content

Commit

Permalink
1.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
iobaixas committed Sep 24, 2014
1 parent e28368e commit 61aa235
Show file tree
Hide file tree
Showing 18 changed files with 141 additions and 103 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,13 @@
<a name="1.1.2"></a>
### 1.1.2 (2014-09-24)

#### Features

* **default_packer:** adds support for explicitly setting links and metadata properties to extract. ([dcfd37be](http://github.com/angular-platanus/restmod/commit/dcfd37be0fb8d5e3c5cb7e2c6a728ab96ee408fe), closes [#153](http://github.com/angular-platanus/restmod/issues/153))
* **find_many:** adds posibility to include additional parameters in populate request ([bf05802b](http://github.com/angular-platanus/restmod/commit/bf05802b7d996c8e7a799f2d003fd2566a60419f))
* **preload:** adds support for query parameters. ([62f1dcb1](http://github.com/angular-platanus/restmod/commit/62f1dcb136652bfb3e413749c67d1b4443958d07), closes [#152](http://github.com/angular-platanus/restmod/issues/152))


<a name="1.1.1"></a>
### 1.1.1 (2014-09-23)

Expand Down
2 changes: 1 addition & 1 deletion bower.json
@@ -1,6 +1,6 @@
{
"name": "angular-restmod",
"version": "1.1.1",
"version": "1.1.2",
"authors": [
"Ignacio Baixas <ignacio@platan.us>"
],
Expand Down
73 changes: 39 additions & 34 deletions dist/angular-restmod-bundle.js
@@ -1,6 +1,6 @@
/**
* API Bound Models for AngularJS
* @version v1.1.1 - 2014-09-23
* @version v1.1.2 - 2014-09-24
* @link https://github.com/angular-platanus/restmod
* @author Ignacio Baixas <ignacio@platan.us>
* @license MIT License, http://www.opensource.org/licenses/MIT
Expand Down Expand Up @@ -3594,38 +3594,30 @@ RMModule.factory('RMSerializer', ['$injector', 'inflector', '$filter', 'RMUtils'
}]);
RMModule.factory('DefaultPacker', ['restmod', 'inflector', 'RMPackerCache', function(restmod, inflector, packerCache) {

// process metadata
function processMeta(_meta, _raw, _skip) {
var metaDef = _meta;
if(typeof metaDef === 'string') {
if(metaDef === '.') {
var meta = {};
for(var key in _raw) {
if(_raw.hasOwnProperty(key) && _skip.indexOf(key) === -1) { // skip links and object root if extracting from root.
meta[key] = _raw[key];
}
}
return meta;
} else {
return _raw[metaDef];
function include(_source, _list, _do) {
for(var i = 0, l = _list.length; i < l; i++) {
_do(_list[i], _source[_list[i]]);
}
}

function exclude(_source, _skip, _do) {
for(var key in _source) {
if(_source.hasOwnProperty(key) && _skip.indexOf(key) === -1) {
_do(key, _source[key]);
}
} else if(typeof metaDef === 'function') {
return metaDef(_raw);
}
}

// process links and stores them in the packer cache
function processLinks(_links, _raw, _skip) {
var source = _links === '.' ? _raw : _raw[_links];
if(!source) return;

// feed packer cache
for(var key in source) {
if(source.hasOwnProperty(key) && _skip.indexOf(key) === -1) {
var cache = source[key];
// TODO: check that cache is an array.
packerCache.feed(key, cache);
}
function processFeature(_raw, _name, _feature, _other, _do) {
if(_feature === '.' || _feature === true) {
var skip = [_name];
if(_other) skip.push.apply(skip, angular.isArray(_other) ? _other : [_other]);
exclude(_raw, skip, _do);
} else if(typeof _feature === 'string') {
exclude(_raw[_feature], [], _do);
} else { // links is an array
include(_raw, _feature, _do);
}
}

Expand Down Expand Up @@ -3658,7 +3650,8 @@ RMModule.factory('DefaultPacker', ['restmod', 'inflector', 'RMPackerCache', func
*
* By default the mixin will look for links to other resources in the 'linked' root property, you
* can change this by setting the jsonLinks variable. To use the root element as link source
* use `jsonLinks: true`. To skip links processing, set it to false.
* use `jsonLinks: '.'`. You can also explicitly select which properties to consider links using an
* array of property names. To skip links processing altogether, set it to false.
*
* Links are expected to use the pluralized version of the name for the referenced model. For example,
* given the following response:
Expand All @@ -3680,9 +3673,9 @@ RMModule.factory('DefaultPacker', ['restmod', 'inflector', 'RMPackerCache', func
* By default metadata is only captured if it comes in the 'meta' root property. Metadata is then
* stored in the $meta property of the resource being unwrapped.
*
* To change the metadata source property set the jsonMeta property to the desired name, set
* it to '.' to capture the entire raw response or set it to false to skip metadata. It can also be set
* to a function, for custom processsing.
* Just like links, to change the metadata source property set the jsonMeta property to the desired name, set
* it to '.' to capture the entire raw response or set it to false to skip metadata and set it to an array of properties
* to be extract selected properties.
*
* @property {mixed} single The expected single resource wrapper property name
* @property {object} plural The expected collection wrapper property name
Expand All @@ -3703,8 +3696,20 @@ RMModule.factory('DefaultPacker', ['restmod', 'inflector', 'RMPackerCache', func
name = this.getProperty('jsonRootSingle') || this.getProperty('jsonRoot') || this.getProperty('name');
}

if(meta) _resource.$metadata = processMeta(meta, _raw, [name, links]);
if(links) processLinks(links, _raw, [name]);
if(meta) {
_resource.$metadata = {};
processFeature(_raw, name, meta, links, function(_key, _value) {
_resource.$metadata[_key] = _value;
});
}

if(links) {
processFeature(_raw, name, links, meta, function(_key, _value) {
// TODO: check that cache is an array.
packerCache.feed(_key, _value);
});
}

return _raw[name];
});
});
Expand Down
4 changes: 2 additions & 2 deletions dist/angular-restmod-bundle.min.js

Large diffs are not rendered by default.

73 changes: 39 additions & 34 deletions dist/angular-restmod.js
@@ -1,6 +1,6 @@
/**
* API Bound Models for AngularJS
* @version v1.1.1 - 2014-09-23
* @version v1.1.2 - 2014-09-24
* @link https://github.com/angular-platanus/restmod
* @author Ignacio Baixas <ignacio@platan.us>
* @license MIT License, http://www.opensource.org/licenses/MIT
Expand Down Expand Up @@ -3356,38 +3356,30 @@ RMModule.factory('RMSerializer', ['$injector', 'inflector', '$filter', 'RMUtils'
}]);
RMModule.factory('DefaultPacker', ['restmod', 'inflector', 'RMPackerCache', function(restmod, inflector, packerCache) {

// process metadata
function processMeta(_meta, _raw, _skip) {
var metaDef = _meta;
if(typeof metaDef === 'string') {
if(metaDef === '.') {
var meta = {};
for(var key in _raw) {
if(_raw.hasOwnProperty(key) && _skip.indexOf(key) === -1) { // skip links and object root if extracting from root.
meta[key] = _raw[key];
}
}
return meta;
} else {
return _raw[metaDef];
function include(_source, _list, _do) {
for(var i = 0, l = _list.length; i < l; i++) {
_do(_list[i], _source[_list[i]]);
}
}

function exclude(_source, _skip, _do) {
for(var key in _source) {
if(_source.hasOwnProperty(key) && _skip.indexOf(key) === -1) {
_do(key, _source[key]);
}
} else if(typeof metaDef === 'function') {
return metaDef(_raw);
}
}

// process links and stores them in the packer cache
function processLinks(_links, _raw, _skip) {
var source = _links === '.' ? _raw : _raw[_links];
if(!source) return;

// feed packer cache
for(var key in source) {
if(source.hasOwnProperty(key) && _skip.indexOf(key) === -1) {
var cache = source[key];
// TODO: check that cache is an array.
packerCache.feed(key, cache);
}
function processFeature(_raw, _name, _feature, _other, _do) {
if(_feature === '.' || _feature === true) {
var skip = [_name];
if(_other) skip.push.apply(skip, angular.isArray(_other) ? _other : [_other]);
exclude(_raw, skip, _do);
} else if(typeof _feature === 'string') {
exclude(_raw[_feature], [], _do);
} else { // links is an array
include(_raw, _feature, _do);
}
}

Expand Down Expand Up @@ -3420,7 +3412,8 @@ RMModule.factory('DefaultPacker', ['restmod', 'inflector', 'RMPackerCache', func
*
* By default the mixin will look for links to other resources in the 'linked' root property, you
* can change this by setting the jsonLinks variable. To use the root element as link source
* use `jsonLinks: true`. To skip links processing, set it to false.
* use `jsonLinks: '.'`. You can also explicitly select which properties to consider links using an
* array of property names. To skip links processing altogether, set it to false.
*
* Links are expected to use the pluralized version of the name for the referenced model. For example,
* given the following response:
Expand All @@ -3442,9 +3435,9 @@ RMModule.factory('DefaultPacker', ['restmod', 'inflector', 'RMPackerCache', func
* By default metadata is only captured if it comes in the 'meta' root property. Metadata is then
* stored in the $meta property of the resource being unwrapped.
*
* To change the metadata source property set the jsonMeta property to the desired name, set
* it to '.' to capture the entire raw response or set it to false to skip metadata. It can also be set
* to a function, for custom processsing.
* Just like links, to change the metadata source property set the jsonMeta property to the desired name, set
* it to '.' to capture the entire raw response or set it to false to skip metadata and set it to an array of properties
* to be extract selected properties.
*
* @property {mixed} single The expected single resource wrapper property name
* @property {object} plural The expected collection wrapper property name
Expand All @@ -3465,8 +3458,20 @@ RMModule.factory('DefaultPacker', ['restmod', 'inflector', 'RMPackerCache', func
name = this.getProperty('jsonRootSingle') || this.getProperty('jsonRoot') || this.getProperty('name');
}

if(meta) _resource.$metadata = processMeta(meta, _raw, [name, links]);
if(links) processLinks(links, _raw, [name]);
if(meta) {
_resource.$metadata = {};
processFeature(_raw, name, meta, links, function(_key, _value) {
_resource.$metadata[_key] = _value;
});
}

if(links) {
processFeature(_raw, name, links, meta, function(_key, _value) {
// TODO: check that cache is an array.
packerCache.feed(_key, _value);
});
}

return _raw[name];
});
});
Expand Down
4 changes: 2 additions & 2 deletions dist/angular-restmod.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/plugins/debounced.js
@@ -1,6 +1,6 @@
/**
* API Bound Models for AngularJS
* @version v1.1.1 - 2014-09-23
* @version v1.1.2 - 2014-09-24
* @link https://github.com/angular-platanus/restmod
* @author Ignacio Baixas <ignacio@platan.us>
* @license MIT License, http://www.opensource.org/licenses/MIT
Expand Down
2 changes: 1 addition & 1 deletion dist/plugins/debounced.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 dist/plugins/dirty.js
@@ -1,6 +1,6 @@
/**
* API Bound Models for AngularJS
* @version v1.1.1 - 2014-09-23
* @version v1.1.2 - 2014-09-24
* @link https://github.com/angular-platanus/restmod
* @author Ignacio Baixas <ignacio@platan.us>
* @license MIT License, http://www.opensource.org/licenses/MIT
Expand Down
2 changes: 1 addition & 1 deletion dist/plugins/dirty.min.js
@@ -1,6 +1,6 @@
/**
* API Bound Models for AngularJS
* @version v1.1.1 - 2014-09-23
* @version v1.1.2 - 2014-09-24
* @link https://github.com/angular-platanus/restmod
* @author Ignacio Baixas <ignacio@platan.us>
* @license MIT License, http://www.opensource.org/licenses/MIT
Expand Down
14 changes: 7 additions & 7 deletions dist/plugins/find-many.js
@@ -1,6 +1,6 @@
/**
* API Bound Models for AngularJS
* @version v1.1.1 - 2014-09-23
* @version v1.1.2 - 2014-09-24
* @link https://github.com/angular-platanus/restmod
* @author Ignacio Baixas <ignacio@platan.us>
* @license MIT License, http://www.opensource.org/licenses/MIT
Expand All @@ -9,7 +9,7 @@
(function(angular, undefined) {
'use strict';
/**
* @mixin Populate
* @mixin FindMany
*
* @description
*
Expand All @@ -23,8 +23,8 @@ angular.module('restmod').factory('restmod.FindMany', ['restmod', 'RMPackerCache
return restmod.mixin(function() {

/**
* @method $populate
* @memberOf Populate
* @method $findManyUrl
* @memberOf FindMany
*
* @description Provides the url for a findMany/populate operation.
*/
Expand All @@ -33,7 +33,7 @@ angular.module('restmod').factory('restmod.FindMany', ['restmod', 'RMPackerCache
})
/**
* @method $populate
* @memberOf Populate
* @memberOf FindMany
*
* @description Resolves a series of records using a single api call.
*
Expand Down Expand Up @@ -63,12 +63,12 @@ angular.module('restmod').factory('restmod.FindMany', ['restmod', 'RMPackerCache
* @param {array} _records Records to resolve.
* @return {Resource} Resource holding the populate promise.
*/
.define('Scope.$populate', function(_records) {
.define('Scope.$populate', function(_records, _params) {

// Extract record pks for non resolved records and build a record map
var pks = [],
recordMap = {},
params = {},
params = _params || {},
model = this.$type,
dummy = model.dummy(true),
record, request;
Expand Down
4 changes: 2 additions & 2 deletions dist/plugins/find-many.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 dist/plugins/paged.js
@@ -1,6 +1,6 @@
/**
* API Bound Models for AngularJS
* @version v1.1.1 - 2014-09-23
* @version v1.1.2 - 2014-09-24
* @link https://github.com/angular-platanus/restmod
* @author Ignacio Baixas <ignacio@platan.us>
* @license MIT License, http://www.opensource.org/licenses/MIT
Expand Down
2 changes: 1 addition & 1 deletion dist/plugins/paged.min.js
@@ -1,6 +1,6 @@
/**
* API Bound Models for AngularJS
* @version v1.1.1 - 2014-09-23
* @version v1.1.2 - 2014-09-24
* @link https://github.com/angular-platanus/restmod
* @author Ignacio Baixas <ignacio@platan.us>
* @license MIT License, http://www.opensource.org/licenses/MIT
Expand Down

0 comments on commit 61aa235

Please sign in to comment.