From 54432c78fa8ab5d3a8209be4446a7f4478f3c66c Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Wed, 1 Dec 2010 20:45:27 -0500 Subject: [PATCH] abstractMethod() moved to util.defineAbstractMethod --- lib/class.js | 26 +------------------------- lib/util.js | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/lib/class.js b/lib/class.js index 5cb9c96..2abc483 100644 --- a/lib/class.js +++ b/lib/class.js @@ -39,31 +39,7 @@ exports.extend = function( base ) } -/** - * 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; -} +exports.abstractMethod = util.createAbstractMethod; /** diff --git a/lib/util.js b/lib/util.js index 6008de9..a438f08 100644 --- a/lib/util.js +++ b/lib/util.js @@ -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 *