1
0
Fork 0

abstractMethod() moved to util.defineAbstractMethod

closure/master
Mike Gerwitz 2010-12-01 20:45:27 -05:00
parent b3c4b757e7
commit 54432c78fa
2 changed files with 29 additions and 25 deletions

View File

@ -39,31 +39,7 @@ exports.extend = function( base )
} }
/** exports.abstractMethod = util.createAbstractMethod;
* Creates an abstract method
*
* Abstract methods must be implemented by a subclass and cannot be called
* directly. If a class contains a single abstract method, the class itself is
* considered to be abstract and cannot be instantiated. It may only be
* extended.
*
* @param {Function} definition function definition that concrete
* implementations must follow
*
* @return {Function}
*/
exports.abstractMethod = function( definition )
{
var method = function()
{
throw new Error( "Cannot call abstract method" );
};
util.defineSecureProp( method, 'abstractFlag', true );
util.defineSecureProp( method, 'definition', definition );
return method;
}
/** /**

View File

@ -186,6 +186,34 @@ exports.propCopy = function( props, dest, result_data )
} }
/**
* Creates an abstract method
*
* Abstract methods must be implemented by a subclass and cannot be called
* directly. If a class contains a single abstract method, the class itself is
* considered to be abstract and cannot be instantiated. It may only be
* extended.
*
* @param {Function} definition function definition that concrete
* implementations must follow
*
* @return {Function}
*/
exports.createAbstractMethod = function( definition )
{
var method = function()
{
throw new Error( "Cannot call abstract method" );
};
exports.defineSecureProp( method, 'abstractFlag', true );
exports.defineSecureProp( method, 'definition', definition );
return method;
}
/** /**
* Overrides a method * Overrides a method
* *