[IMP] add ability to return a different object (than 'this') from Class.init, for factory-type scenarios

bzr revid: xmo@openerp.com-20110517095923-8lr1pjelf94nwu44
This commit is contained in:
Xavier Morel
2011-05-17 11:59:23 +02:00
parent fba3f1bfc7
commit a656834516
+5 -2
View File
@@ -44,8 +44,11 @@
// The dummy class constructor
function Class() {
// All construction is actually done in the init method
if ( !initializing && this.init )
this.init.apply(this, arguments);
if ( !initializing && this.init ) {
var ret = this.init.apply(this, arguments);
if (ret) { return ret; }
}
return this;
}
// Populate our constructed prototype object