mirror of
https://github.com/kbparagua/paloma
synced 2023-03-27 23:21:17 -04:00
controller and action property
This commit is contained in:
parent
6d9e22e85f
commit
b13d65e514
2 changed files with 16 additions and 3 deletions
|
@ -31,7 +31,7 @@ describe('Paloma.ControllerBuilder', function(){
|
||||||
expect(controller instanceof TestController).toBeTruthy();
|
expect(controller instanceof TestController).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("initializes controller instance's params", function(){
|
it("initializes controller instance's params property", function(){
|
||||||
var expectedParams = {a: 1, b: 2};
|
var expectedParams = {a: 1, b: 2};
|
||||||
var correct = true;
|
var correct = true;
|
||||||
|
|
||||||
|
@ -43,6 +43,14 @@ describe('Paloma.ControllerBuilder', function(){
|
||||||
|
|
||||||
expect(correct).toBeTruthy();
|
expect(correct).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("initializes controller instance's controller property", function(){
|
||||||
|
expect(controller.controller).toEqual('Test');
|
||||||
|
});
|
||||||
|
|
||||||
|
it("initializes controller instance's action property", function(){
|
||||||
|
expect(controller.action).toEqual('show');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -11,7 +11,12 @@ Paloma.ControllerBuilder.prototype = {
|
||||||
var ControllerClass = this._controllerClass();
|
var ControllerClass = this._controllerClass();
|
||||||
if ( !ControllerClass ) return null;
|
if ( !ControllerClass ) return null;
|
||||||
|
|
||||||
return new ControllerClass( this._buildParams() );
|
var controller = new ControllerClass( this._buildParams() );
|
||||||
|
|
||||||
|
controller.controller = this.options.controller;
|
||||||
|
controller.action = this.options.action;
|
||||||
|
|
||||||
|
return controller;
|
||||||
},
|
},
|
||||||
|
|
||||||
_controllerClass: function(){
|
_controllerClass: function(){
|
||||||
|
@ -20,7 +25,7 @@ Paloma.ControllerBuilder.prototype = {
|
||||||
|
|
||||||
_buildParams: function(){
|
_buildParams: function(){
|
||||||
var params = {};
|
var params = {};
|
||||||
|
|
||||||
for (var k in this.options.params)
|
for (var k in this.options.params)
|
||||||
if (this.options.params.hasOwnProperty(k))
|
if (this.options.params.hasOwnProperty(k))
|
||||||
params[k] = this.options.params[k];
|
params[k] = this.options.params[k];
|
||||||
|
|
Loading…
Reference in a new issue