diff --git a/lib/util.js b/lib/util.js index 15bfef0..3c0ef92 100644 --- a/lib/util.js +++ b/lib/util.js @@ -96,9 +96,10 @@ exports.defineSecureProp = function( obj, prop, value ) */ exports.propParse = function( data, options ) { - var callback_prop = options.property || function() {}, - callback_method = options.method || function() {}, - callback = null; + var callback_prop = options.property || function() {}, + callback_method = options.method || function() {}, + callback_abstract_method = options.abstractMethod || function() {}, + callback = null; // for each of the given properties, determine what type of property we're // dealing with (in the classic OO sense) @@ -108,7 +109,11 @@ exports.propParse = function( data, options ) if ( value instanceof Function ) { - callback = callback_method; + // concrete or abstract? + callback = ( exports.isAbstractMethod( value ) ) + ? callback_abstract_method + : callback_method + ; } else { diff --git a/test/test-util-prop-parse.js b/test/test-util-prop-parse.js index dc6e45b..269e367 100644 --- a/test/test-util-prop-parse.js +++ b/test/test-util-prop-parse.js @@ -24,8 +24,8 @@ require( './common' ); -var assert = require( 'assert' ), - propParse = require( '../lib/util' ).propParse; +var assert = require( 'assert' ), + util = require( '../lib/util' ); var data = { // scalars (properties) @@ -42,13 +42,17 @@ var data = { // concrete method method: function() {}, + + // abstract method + abstractMethod: util.createAbstractMethod(), }; -var props = {}, - methods = {}; +var props = {}, + methods = {}, + amethods = {}; -propParse( data, { +util.propParse( data, { property: function( name, value ) { props[ name ] = value; @@ -59,6 +63,11 @@ propParse( data, { { methods[ name ] = method; }, + + abstractMethod: function( name, def ) + { + amethods[ name ] = def; + } } ); @@ -76,6 +85,12 @@ propParse( data, { assert.equal( methods.method, data.method, - "Property parser properly detects methods" + "Property parser properly detects concrete methods" +); + +assert.equal( + amethods.abstractMethod, + data.abstractMethod, + "Property parser properly detects abstract methods" );