Skip to content

Commit 61aa235

Browse files
committed
1.1.2
1 parent e28368e commit 61aa235

18 files changed

+141
-103
lines changed

CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
<a name="1.1.2"></a>
2+
### 1.1.2 (2014-09-24)
3+
4+
#### Features
5+
6+
* **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))
7+
* **find_many:** adds posibility to include additional parameters in populate request ([bf05802b](http://github.com/angular-platanus/restmod/commit/bf05802b7d996c8e7a799f2d003fd2566a60419f))
8+
* **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))
9+
10+
111
<a name="1.1.1"></a>
212
### 1.1.1 (2014-09-23)
313

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-restmod",
3-
"version": "1.1.1",
3+
"version": "1.1.2",
44
"authors": [
55
"Ignacio Baixas <[email protected]>"
66
],

dist/angular-restmod-bundle.js

+39-34
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* API Bound Models for AngularJS
3-
* @version v1.1.1 - 2014-09-23
3+
* @version v1.1.2 - 2014-09-24
44
* @link https://github.com/angular-platanus/restmod
55
* @author Ignacio Baixas <[email protected]>
66
* @license MIT License, http://www.opensource.org/licenses/MIT
@@ -3594,38 +3594,30 @@ RMModule.factory('RMSerializer', ['$injector', 'inflector', '$filter', 'RMUtils'
35943594
}]);
35953595
RMModule.factory('DefaultPacker', ['restmod', 'inflector', 'RMPackerCache', function(restmod, inflector, packerCache) {
35963596

3597-
// process metadata
3598-
function processMeta(_meta, _raw, _skip) {
3599-
var metaDef = _meta;
3600-
if(typeof metaDef === 'string') {
3601-
if(metaDef === '.') {
3602-
var meta = {};
3603-
for(var key in _raw) {
3604-
if(_raw.hasOwnProperty(key) && _skip.indexOf(key) === -1) { // skip links and object root if extracting from root.
3605-
meta[key] = _raw[key];
3606-
}
3607-
}
3608-
return meta;
3609-
} else {
3610-
return _raw[metaDef];
3597+
function include(_source, _list, _do) {
3598+
for(var i = 0, l = _list.length; i < l; i++) {
3599+
_do(_list[i], _source[_list[i]]);
3600+
}
3601+
}
3602+
3603+
function exclude(_source, _skip, _do) {
3604+
for(var key in _source) {
3605+
if(_source.hasOwnProperty(key) && _skip.indexOf(key) === -1) {
3606+
_do(key, _source[key]);
36113607
}
3612-
} else if(typeof metaDef === 'function') {
3613-
return metaDef(_raw);
36143608
}
36153609
}
36163610

36173611
// process links and stores them in the packer cache
3618-
function processLinks(_links, _raw, _skip) {
3619-
var source = _links === '.' ? _raw : _raw[_links];
3620-
if(!source) return;
3621-
3622-
// feed packer cache
3623-
for(var key in source) {
3624-
if(source.hasOwnProperty(key) && _skip.indexOf(key) === -1) {
3625-
var cache = source[key];
3626-
// TODO: check that cache is an array.
3627-
packerCache.feed(key, cache);
3628-
}
3612+
function processFeature(_raw, _name, _feature, _other, _do) {
3613+
if(_feature === '.' || _feature === true) {
3614+
var skip = [_name];
3615+
if(_other) skip.push.apply(skip, angular.isArray(_other) ? _other : [_other]);
3616+
exclude(_raw, skip, _do);
3617+
} else if(typeof _feature === 'string') {
3618+
exclude(_raw[_feature], [], _do);
3619+
} else { // links is an array
3620+
include(_raw, _feature, _do);
36293621
}
36303622
}
36313623

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

3706-
if(meta) _resource.$metadata = processMeta(meta, _raw, [name, links]);
3707-
if(links) processLinks(links, _raw, [name]);
3699+
if(meta) {
3700+
_resource.$metadata = {};
3701+
processFeature(_raw, name, meta, links, function(_key, _value) {
3702+
_resource.$metadata[_key] = _value;
3703+
});
3704+
}
3705+
3706+
if(links) {
3707+
processFeature(_raw, name, links, meta, function(_key, _value) {
3708+
// TODO: check that cache is an array.
3709+
packerCache.feed(_key, _value);
3710+
});
3711+
}
3712+
37083713
return _raw[name];
37093714
});
37103715
});

dist/angular-restmod-bundle.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/angular-restmod.js

+39-34
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* API Bound Models for AngularJS
3-
* @version v1.1.1 - 2014-09-23
3+
* @version v1.1.2 - 2014-09-24
44
* @link https://github.com/angular-platanus/restmod
55
* @author Ignacio Baixas <[email protected]>
66
* @license MIT License, http://www.opensource.org/licenses/MIT
@@ -3356,38 +3356,30 @@ RMModule.factory('RMSerializer', ['$injector', 'inflector', '$filter', 'RMUtils'
33563356
}]);
33573357
RMModule.factory('DefaultPacker', ['restmod', 'inflector', 'RMPackerCache', function(restmod, inflector, packerCache) {
33583358

3359-
// process metadata
3360-
function processMeta(_meta, _raw, _skip) {
3361-
var metaDef = _meta;
3362-
if(typeof metaDef === 'string') {
3363-
if(metaDef === '.') {
3364-
var meta = {};
3365-
for(var key in _raw) {
3366-
if(_raw.hasOwnProperty(key) && _skip.indexOf(key) === -1) { // skip links and object root if extracting from root.
3367-
meta[key] = _raw[key];
3368-
}
3369-
}
3370-
return meta;
3371-
} else {
3372-
return _raw[metaDef];
3359+
function include(_source, _list, _do) {
3360+
for(var i = 0, l = _list.length; i < l; i++) {
3361+
_do(_list[i], _source[_list[i]]);
3362+
}
3363+
}
3364+
3365+
function exclude(_source, _skip, _do) {
3366+
for(var key in _source) {
3367+
if(_source.hasOwnProperty(key) && _skip.indexOf(key) === -1) {
3368+
_do(key, _source[key]);
33733369
}
3374-
} else if(typeof metaDef === 'function') {
3375-
return metaDef(_raw);
33763370
}
33773371
}
33783372

33793373
// process links and stores them in the packer cache
3380-
function processLinks(_links, _raw, _skip) {
3381-
var source = _links === '.' ? _raw : _raw[_links];
3382-
if(!source) return;
3383-
3384-
// feed packer cache
3385-
for(var key in source) {
3386-
if(source.hasOwnProperty(key) && _skip.indexOf(key) === -1) {
3387-
var cache = source[key];
3388-
// TODO: check that cache is an array.
3389-
packerCache.feed(key, cache);
3390-
}
3374+
function processFeature(_raw, _name, _feature, _other, _do) {
3375+
if(_feature === '.' || _feature === true) {
3376+
var skip = [_name];
3377+
if(_other) skip.push.apply(skip, angular.isArray(_other) ? _other : [_other]);
3378+
exclude(_raw, skip, _do);
3379+
} else if(typeof _feature === 'string') {
3380+
exclude(_raw[_feature], [], _do);
3381+
} else { // links is an array
3382+
include(_raw, _feature, _do);
33913383
}
33923384
}
33933385

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

3468-
if(meta) _resource.$metadata = processMeta(meta, _raw, [name, links]);
3469-
if(links) processLinks(links, _raw, [name]);
3461+
if(meta) {
3462+
_resource.$metadata = {};
3463+
processFeature(_raw, name, meta, links, function(_key, _value) {
3464+
_resource.$metadata[_key] = _value;
3465+
});
3466+
}
3467+
3468+
if(links) {
3469+
processFeature(_raw, name, links, meta, function(_key, _value) {
3470+
// TODO: check that cache is an array.
3471+
packerCache.feed(_key, _value);
3472+
});
3473+
}
3474+
34703475
return _raw[name];
34713476
});
34723477
});

dist/angular-restmod.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/plugins/debounced.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* API Bound Models for AngularJS
3-
* @version v1.1.1 - 2014-09-23
3+
* @version v1.1.2 - 2014-09-24
44
* @link https://github.com/angular-platanus/restmod
55
* @author Ignacio Baixas <[email protected]>
66
* @license MIT License, http://www.opensource.org/licenses/MIT

dist/plugins/debounced.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/plugins/dirty.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* API Bound Models for AngularJS
3-
* @version v1.1.1 - 2014-09-23
3+
* @version v1.1.2 - 2014-09-24
44
* @link https://github.com/angular-platanus/restmod
55
* @author Ignacio Baixas <[email protected]>
66
* @license MIT License, http://www.opensource.org/licenses/MIT

dist/plugins/dirty.min.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* API Bound Models for AngularJS
3-
* @version v1.1.1 - 2014-09-23
3+
* @version v1.1.2 - 2014-09-24
44
* @link https://github.com/angular-platanus/restmod
55
* @author Ignacio Baixas <[email protected]>
66
* @license MIT License, http://www.opensource.org/licenses/MIT

dist/plugins/find-many.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* API Bound Models for AngularJS
3-
* @version v1.1.1 - 2014-09-23
3+
* @version v1.1.2 - 2014-09-24
44
* @link https://github.com/angular-platanus/restmod
55
* @author Ignacio Baixas <[email protected]>
66
* @license MIT License, http://www.opensource.org/licenses/MIT
@@ -9,7 +9,7 @@
99
(function(angular, undefined) {
1010
'use strict';
1111
/**
12-
* @mixin Populate
12+
* @mixin FindMany
1313
*
1414
* @description
1515
*
@@ -23,8 +23,8 @@ angular.module('restmod').factory('restmod.FindMany', ['restmod', 'RMPackerCache
2323
return restmod.mixin(function() {
2424

2525
/**
26-
* @method $populate
27-
* @memberOf Populate
26+
* @method $findManyUrl
27+
* @memberOf FindMany
2828
*
2929
* @description Provides the url for a findMany/populate operation.
3030
*/
@@ -33,7 +33,7 @@ angular.module('restmod').factory('restmod.FindMany', ['restmod', 'RMPackerCache
3333
})
3434
/**
3535
* @method $populate
36-
* @memberOf Populate
36+
* @memberOf FindMany
3737
*
3838
* @description Resolves a series of records using a single api call.
3939
*
@@ -63,12 +63,12 @@ angular.module('restmod').factory('restmod.FindMany', ['restmod', 'RMPackerCache
6363
* @param {array} _records Records to resolve.
6464
* @return {Resource} Resource holding the populate promise.
6565
*/
66-
.define('Scope.$populate', function(_records) {
66+
.define('Scope.$populate', function(_records, _params) {
6767

6868
// Extract record pks for non resolved records and build a record map
6969
var pks = [],
7070
recordMap = {},
71-
params = {},
71+
params = _params || {},
7272
model = this.$type,
7373
dummy = model.dummy(true),
7474
record, request;

dist/plugins/find-many.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/plugins/paged.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* API Bound Models for AngularJS
3-
* @version v1.1.1 - 2014-09-23
3+
* @version v1.1.2 - 2014-09-24
44
* @link https://github.com/angular-platanus/restmod
55
* @author Ignacio Baixas <[email protected]>
66
* @license MIT License, http://www.opensource.org/licenses/MIT

dist/plugins/paged.min.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* API Bound Models for AngularJS
3-
* @version v1.1.1 - 2014-09-23
3+
* @version v1.1.2 - 2014-09-24
44
* @link https://github.com/angular-platanus/restmod
55
* @author Ignacio Baixas <[email protected]>
66
* @license MIT License, http://www.opensource.org/licenses/MIT

0 commit comments

Comments
 (0)