diff --git a/lib/class.js b/lib/class.js index c692b3b..6ab2544 100644 --- a/lib/class.js +++ b/lib/class.js @@ -355,13 +355,12 @@ function extend() // set up the new class var data = class_builder.build.apply( null, arguments ), - new_class = data[ 'class' ], - abstract_methods = data.abstractMethods, - class_id = data.classId + new_class = data[ 'class' ], + class_id = data.classId ; // important: call after setting prototype - setupProps( new_class, abstract_methods, class_id ); + setupProps( new_class, class_id ); // lock down the new class (if supported) to ensure that we can't add // members at runtime @@ -419,46 +418,19 @@ var implement = function() /** * Sets up common properties for the provided function (class) * - * @param {function()} func function (class) to set up - * @param {Array.} abstract_methods list of abstract method names - * @param {number} class_id unique id to assign to class + * @param {function()} func function (class) to set up + * @param {number} class_id unique id to assign to class * * @return {undefined} */ -function setupProps( func, abstract_methods, class_id ) +function setupProps( func, class_id ) { - attachAbstract( func, abstract_methods ); attachExtend( func ); attachImplement( func ); attachId( func, class_id ); } -/** - * Attaches isAbstract() method to the class - * - * @param {Function} func function (class) to attach method to - * @param {Array} methods abstract method names - * - * @return {undefined} - */ -function attachAbstract( func, methods ) -{ - var is_abstract = ( methods.__length > 0 ) ? true: false; - - /** - * Returns whether the class contains abstract methods (and is therefore - * abstract) - * - * @return {Boolean} true if class is abstract, otherwise false - */ - util.defineSecureProp( func, 'isAbstract', function() - { - return is_abstract; - }); -} - - /** * Attaches extend method to the given function (class) * diff --git a/lib/class_builder.js b/lib/class_builder.js index 3a0d93e..cb1e52a 100644 --- a/lib/class_builder.js +++ b/lib/class_builder.js @@ -216,13 +216,14 @@ exports.build = function extend() meta.abstractMethods = abstract_methods; meta.name = cname; + attachAbstract( new_class, abstract_methods ); + // we're done with the extension process extending = false; return { - 'class': new_class, - abstractMethods: abstract_methods, - classId: class_id, + 'class': new_class, + classId: class_id, }; }; @@ -726,3 +727,28 @@ exports.isInstanceOf = function( type, instance ) return false; }; + +/** + * Attaches isAbstract() method to the class + * + * @param {Function} func function (class) to attach method to + * @param {Array} methods abstract method names + * + * @return {undefined} + */ +function attachAbstract( func, methods ) +{ + var is_abstract = ( methods.__length > 0 ) ? true: false; + + /** + * Returns whether the class contains abstract methods (and is therefore + * abstract) + * + * @return {Boolean} true if class is abstract, otherwise false + */ + util.defineSecureProp( func, 'isAbstract', function() + { + return is_abstract; + }); +} +