diff --git a/lib/util.js b/lib/util.js index eb6b3b2..a1b7da6 100644 --- a/lib/util.js +++ b/lib/util.js @@ -96,14 +96,12 @@ exports.defineSecureProp = function( obj, prop, value ) */ exports.propParse = function( data, options ) { - var fvoid = function() {}, - callback_each = options.each || undefined, - callback_prop = options.property || fvoid, - callback_method = options.method || fvoid, - callback_abstract_method = options.abstractMethod || fvoid, - callback_getter = options.getter || fvoid, - callback_setter = options.setter || fvoid, - callback = null; + var fvoid = function() {}, + callback_each = options.each || undefined, + callback_prop = options.property || fvoid, + callback_method = options.method || fvoid, + callback_getter = options.getter || fvoid, + callback_setter = options.setter || fvoid; // for each of the given properties, determine what type of property we're // dealing with (in the classic OO sense) @@ -131,20 +129,17 @@ exports.propParse = function( data, options ) // method else if ( value instanceof Function ) { - // concrete or abstract? - callback = ( exports.isAbstractMethod( value ) ) - ? callback_abstract_method - : callback_method - ; + callback_method( + prop, + value, + exports.isAbstractMethod( value ) + ); } // simple property else { - callback = callback_prop; + callback_prop( prop, value ); } - - // call the appropriate callback - callback( prop, value ); } } @@ -232,28 +227,7 @@ exports.propCopy = function( props, dest, result_data ) dest.__defineSetter__( name, func ); }, - abstractMethod: function( name, def ) - { - var data = { abstractModified: false }, - pre = dest[ name ]; - - // check for override - if ( pre !== undefined ) - { - dest[ name ] = attempt_override( name, pre, def, data ); - if ( data.abstractModified ) - { - abstract_regen = true; - } - } - else - { - abstract_methods.push( name ); - dest[ name ] = def; - } - }, - - method: function( name, func ) + method: function( name, func, is_abstract ) { var data = { abstractModified: false }, pre = dest[ name ]; @@ -271,6 +245,11 @@ exports.propCopy = function( props, dest, result_data ) { // simply copy over the method dest[ name ] = func; + + if ( is_abstract ) + { + abstract_methods.push( name ); + } } }, }; diff --git a/test/test-util-prop-parse.js b/test/test-util-prop-parse.js index 6c66740..9e554e0 100644 --- a/test/test-util-prop-parse.js +++ b/test/test-util-prop-parse.js @@ -80,15 +80,10 @@ util.propParse( data, { props[ name ] = value; }, - // concrete method - method: function( name, method ) + method: function( name, method, is_abstract ) { - methods[ name ] = method; - }, - - abstractMethod: function( name, def ) - { - amethods[ name ] = def; + var to = ( is_abstract ) ? amethods : methods; + to[ name ] = method; }, getter: function( name, func )