From 67dac667cfaaae113f42ad6aecd5417f8677c3d0 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Wed, 5 Nov 2014 16:25:34 -0800 Subject: [PATCH] [Framework] Change cardinality of custom registrars Change cardinality of custom registrars from one to many; this will permit treating the service compositor as a custom registrar. WTD-518. --- .../framework/src/register/CustomRegistrars.js | 16 ++++++++++++---- .../framework/src/register/ExtensionRegistrar.js | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/platform/framework/src/register/CustomRegistrars.js b/platform/framework/src/register/CustomRegistrars.js index f44f2de8db..2ac85b1183 100644 --- a/platform/framework/src/register/CustomRegistrars.js +++ b/platform/framework/src/register/CustomRegistrars.js @@ -75,14 +75,22 @@ define( }]); } + // Utility; create a function which converts another function + // (which acts on single objects) to one which acts upon arrays. + function mapUpon(func) { + return function(array) { + return array.map(func); + }; + } + // More like key-value pairs than methods; key is the // name of the extension category to be handled, and the value // is the function which handles it. return { - routes: registerRoute, - directives: new CustomRegistrar("directive"), - controllers: new CustomRegistrar("controller"), - services: new CustomRegistrar("service") + routes: mapUpon(registerRoute), + directives: mapUpon(new CustomRegistrar("directive")), + controllers: mapUpon(new CustomRegistrar("controller")), + services: mapUpon(new CustomRegistrar("service")) }; } diff --git a/platform/framework/src/register/ExtensionRegistrar.js b/platform/framework/src/register/ExtensionRegistrar.js index 6d09a4a3a7..69464c2d47 100644 --- a/platform/framework/src/register/ExtensionRegistrar.js +++ b/platform/framework/src/register/ExtensionRegistrar.js @@ -91,7 +91,7 @@ define( // code for services, directives, etc; otherwise, // just register them under generic names. if (customRegistrars[category]) { - extensions.forEach(customRegistrars[category]); + customRegistrars[category](extensions); } else { extensions.forEach(registerExtension); registerExtensionArraysForCategory(category, names);