mirror of
https://github.com/kbparagua/paloma
synced 2023-03-27 23:21:17 -04:00
Rename files controller_builder to controller_factory
This commit is contained in:
parent
216511c5f6
commit
43d11ee081
3 changed files with 1 additions and 56 deletions
|
@ -1,55 +0,0 @@
|
|||
(function(Paloma){
|
||||
|
||||
|
||||
var ControllerFactory = function(router){
|
||||
this.instances = {};
|
||||
this.router = router;
|
||||
};
|
||||
|
||||
|
||||
ControllerFactory.prototype.make = function(name){
|
||||
var config = this.router.parse(name),
|
||||
scope = this.instances;
|
||||
|
||||
// Create namespaces.
|
||||
for (var i = 0, n = config['namespaces'].length; i < n; i++){
|
||||
var namespace = config['namespaces'][i];
|
||||
scope[namespace] = scope[namespace] || {};
|
||||
scope = scope[namespace];
|
||||
}
|
||||
|
||||
return scope[config['controller']] = createConstructor();
|
||||
};
|
||||
|
||||
|
||||
ControllerFactory.prototype.get = function(name){
|
||||
var config = this.router.parse(name),
|
||||
scope = this.instances;
|
||||
|
||||
for (var i = 0, n = config['controllerPath'].length; i < n; i++){
|
||||
var path = config['controllerPath'][i];
|
||||
|
||||
if (scope[path] != null){ scope = scope[path]; }
|
||||
else { return null; }
|
||||
}
|
||||
|
||||
return scope;
|
||||
};
|
||||
|
||||
|
||||
var createConstructor = function(){
|
||||
var constructor = function(params){ this.params = params; }
|
||||
|
||||
$.extend(constructor, Paloma.Controller);
|
||||
$.extend(constructor.prototype, Paloma.Controller.prototype);
|
||||
|
||||
return constructor;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Paloma.ControllerFactory = ControllerFactory;
|
||||
|
||||
})(window.Paloma);
|
2
vendor/assets/javascripts/paloma/index.js
vendored
2
vendor/assets/javascripts/paloma/index.js
vendored
|
@ -1,6 +1,6 @@
|
|||
//= require ./init.js
|
||||
//= require ./router.js
|
||||
//= require ./controller.js
|
||||
//= require ./controller_builder.js
|
||||
//= require ./controller_factory.js
|
||||
//= require ./engine.js
|
||||
//= require ./paloma.js
|
Loading…
Reference in a new issue