lib/dependency.injector.js
function injectFlapjack(flapjack, moduleStack, options) {
        options = options || {};

        // if server is false, then return null
        var moduleInfo = annotations.getModuleInfo(flapjack);
        if (moduleInfo && moduleInfo.server === false && !options.test) {
            return null;
        }

        // param map is combo of param map set by user, params discovered and current annotation
        var aliases = _.extend({}, this.aliases, annotations.getServerAliases(flapjack, null));
        var params = annotations.getParameters(flapjack);
        var deps = options.dependencies || {};
        var paramModules = [];
        var me = this;

        // loop through the params so we can collect the object that will be injected
        _.each(params, function (param) {
            var dep = deps[param];

            // if mapping exists, switch to the mapping (ex. pancakes -> lib/pancakes)
            if (aliases[param]) {
                param = aliases[param];
            }

            // either get the module from the input dependencies or recursively call inject
            try {
                paramModules.push(dep || deps[param] || me.loadModule(param, moduleStack));
            }
            catch (ex) {
                var errMsg = ex.stack || ex;
                throw new Error('While injecting function, ran into invalid parameter.\nparam: ' + param +
                '\nstack: ' + JSON.stringify(moduleStack) + '\nfunction: ' +
                flapjack.toString().substring(0, 100) + '...\nerror: ' + errMsg);
            }
        });

        // call the flapjack function passing in the array of modules as parameters
        return flapjack.apply(null, paramModules);
    }
function injectFlapjack(flapjack, moduleStack, options) {
        options = options || {};

        // if server is false, then return null
        var moduleInfo = annotations.getModuleInfo(flapjack);
        if (moduleInfo && moduleInfo.server === false && !options.test) {
            return null;
        }

        // param map is combo of param map set by user, params discovered and current annotation
        var aliases = _.extend({}, this.aliases, annotations.getServerAliases(flapjack, null));
        var params = annotations.getParameters(flapjack);
        var deps = options.dependencies || {};
        var paramModules = [];
        var me = this;

        // loop through the params so we can collect the object that will be injected
        _.each(params, function (param) {
            var dep = deps[param];

            // if mapping exists, switch to the mapping (ex. pancakes -> lib/pancakes)
            if (aliases[param]) {
                param = aliases[param];
            }

            // either get the module from the input dependencies or recursively call inject
            try {
                paramModules.push(dep || deps[param] || me.loadModule(param, moduleStack));
            }
            catch (ex) {
                var errMsg = ex.stack || ex;
                throw new Error('While injecting function, ran into invalid parameter.\nparam: ' + param +
                '\nstack: ' + JSON.stringify(moduleStack) + '\nfunction: ' +
                flapjack.toString().substring(0, 100) + '...\nerror: ' + errMsg);
            }
        });

        // call the flapjack function passing in the array of modules as parameters
        return flapjack.apply(null, paramModules);
    }
function injectFlapjack ( flapjack , moduleStack , options ) { options = options || { } ; // if server is false, then return null var moduleInfo = annotations . getModuleInfo ( flapjack ) ; if ( moduleInfo && moduleInfo . server === false && ! options . test ) { return null ; } // param map is combo of param map set by user, params discovered and current annotation var aliases = _ . extend ( { } , this . aliases , annotations . getServerAliases ( flapjack , null ) ) ; var params = annotations . getParameters ( flapjack ) ; var deps = options . dependencies || { } ; var paramModules = [ ] ; var me = this ; // loop through the params so we can collect the object that will be injected _ . each ( params , function ( param ) { var dep = deps [ param ] ; // if mapping exists, switch to the mapping (ex. pancakes -> lib/pancakes) if ( aliases [ param ] ) { param = aliases [ param ] ; } // either get the module from the input dependencies or recursively call inject try { paramModules . push ( dep || deps [ param ] || me . loadModule ( param , moduleStack ) ) ; } catch ( ex ) { var errMsg = ex . stack || ex ; throw new Error ( 'While injecting function, ran into invalid parameter.\nparam: ' + param + '\nstack: ' + JSON . stringify ( moduleStack ) + '\nfunction: ' + flapjack . toString ( ) . substring ( 0 , 100 ) + '...\nerror: ' + errMsg ) ; } } ) ; // call the flapjack function passing in the array of modules as parameters return flapjack . apply ( null , paramModules ) ; }
Given a flapjack load all the params and instantiated it. This fn is used by
the FlapjackFactory and ModulePluginFactory.

@param flapjack
@param moduleStack
@param options
@returns {*}
Given a flapjack load all the params and instantiated it . This fn is used by the FlapjackFactory and ModulePluginFactory .