Skip to content

Commit

Permalink
Allow to delegate custom keys in configurator
Browse files Browse the repository at this point in the history
  • Loading branch information
LFDM committed May 27, 2014
1 parent eb6521d commit cd3e591
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/js/arethusa.core/configurator.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ angular.module('arethusa.core').service('configurator', function($injector, $htt
conf.resources[plugin];
};

function newStandardProperties() {
function standardProperties() {
return [
'name',
'main',
Expand All @@ -232,8 +232,8 @@ angular.module('arethusa.core').service('configurator', function($injector, $htt
}
// Delegates a set of standard properties to the given object to allow
// a more direct access.
this.delegateConf = function(obj) {
var props = newStandardProperties();
this.delegateConf = function(obj, otherKeys) {
var props = arethusaUtil.pushAll(standardProperties(), otherKeys);
angular.forEach(props, function(property, i) {
obj[property] = obj.conf[property];
});
Expand Down
23 changes: 23 additions & 0 deletions spec/arethusa.core/configurator.service_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,29 @@ describe('configurator', function() {
expect(obj.hasOwnProperty(key)).toBeTruthy();
});
}));

it('an array of additional properties to delegate can be given', inject(function(configurator) {
configurator.configuration = conf1;
var obj = {};
var results = [
'name',
'main',
'template',
'external',
'listener',
'contextMenu',
'noView',
'a',
'b'
];

obj.conf = configurator.configurationFor('morph');
configurator.delegateConf(obj, ['a', 'b']);

angular.forEach(results, function(key, i) {
expect(obj.hasOwnProperty(key)).toBeTruthy();
});
}));
});

describe('this.getService', function() {
Expand Down

0 comments on commit cd3e591

Please sign in to comment.