function loadModels(path, cb) {
	// Get the main model files
	buildDictionary.optional({
		dirname: path,
		filter: /^([^.]+)\.(js|coffee|litcoffee)$/,
		replaceExpr: /^.*\//,
        flattenDirectories: true
	}, function(err, models) {
		if(err) { return cb(err); }
		// Get any supplumental files
		buildDictionary.optional({
			dirname: path,
         	filter: /(.+)\.attributes.json$/,
         	replaceExpr: /^.*\//,
         	flattenDirectories: true
		}, function(err, supplements) {
			// bindToSails function from sails/lib/hooks/moduleloader/index.js
			if(err) { return cb(err) }
			_.each(supplements, function(module) {
				// Bind all methods to the module context
				_.bindAll(module);
			});
			return cb(null, _.merge(models, supplements)) 
		});
	});
}
// code from sails/lib/hooks/moduleloader/index.js loadModels function
code from sails/lib/hooks/moduleloader/index.js loadModels function
code from sails / lib / hooks / moduleloader / index . js loadModels function
function loadModels(path, cb) {
	buildDictionary.optional({
		dirname: path,
		filter: /^([^.]+)\.(js|coffee|litcoffee)$/,
		replaceExpr: /^.*\//,
        flattenDirectories: true
	}, function(err, models) {
		if(err) { return cb(err); }
		buildDictionary.optional({
			dirname: path,
         	filter: /(.+)\.attributes.json$/,
         	replaceExpr: /^.*\//,
         	flattenDirectories: true
		}, function(err, supplements) {
			if(err) { return cb(err) }
			_.each(supplements, function(module) {
				_.bindAll(module);
			});
			return cb(null, _.merge(models, supplements)) 
		});
	});
}
function loadModels ( path , cb ) { buildDictionary . optional ( { dirname : path , filter : / ^([^.]+)\.(js|coffee|litcoffee)$ / , replaceExpr : / ^.*\/ / , flattenDirectories : true } , function ( err , models ) { if ( err ) { return cb ( err ) ; } buildDictionary . optional ( { dirname : path , filter : / (.+)\.attributes.json$ / , replaceExpr : / ^.*\/ / , flattenDirectories : true } , function ( err , supplements ) { if ( err ) { return cb ( err ) } _ . each ( supplements , function ( module ) { _ . bindAll ( module ) ; } ) ; return cb ( null , _ . merge ( models , supplements ) ) } ) ; } ) ; }
code from sails/lib/hooks/moduleloader/index.js loadModels function
code from sails / lib / hooks / moduleloader / index . js loadModels function
// Get the main model files // Get any supplumental files // bindToSails function from sails/lib/hooks/moduleloader/index.js // Bind all methods to the module context