From dea6972416776e79fc1e953e90e5ced3b1f012aa Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Fri, 21 Jan 2011 20:54:55 -0500 Subject: [PATCH] Began adding basic method builder (currently operates the same as property builder) - They are essentially the same, but the method builder will have additional logic (e.g. method overriding) and support different keywords --- lib/member_builder.js | 20 ++++++++++++++++++ test/test-member_builder-method.js | 34 ++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 test/test-member_builder-method.js diff --git a/lib/member_builder.js b/lib/member_builder.js index 8ad023b..c11ab06 100644 --- a/lib/member_builder.js +++ b/lib/member_builder.js @@ -45,6 +45,26 @@ exports.initMembers = function( mpublic, mprotected, mprivate ) }; +/** + * Copies a method to the appropriate member prototype, depending on + * visibility, and assigns necessary metadata from keywords + * + * @param {{public: Object, protected: Object, private: Object}} members + * + * @param {Object} meta metadata container + * @param {string} name property name + * @param {*} value property value + * + * @param {Object.} keywords parsed keywords + * + * @return {undefined} + */ +exports.buildMethod = function( members, meta, name, value, keywords ) +{ + getMemberVisibility( members, keywords )[ name ] = value; +}; + + /** * Copies a property to the appropriate member prototype, depending on * visibility, and assigns necessary metadata from keywords diff --git a/test/test-member_builder-method.js b/test/test-member_builder-method.js new file mode 100644 index 0000000..5fb35d3 --- /dev/null +++ b/test/test-member_builder-method.js @@ -0,0 +1,34 @@ +/** + * Tests method builder + * + * Copyright (C) 2010 Mike Gerwitz + * + * This file is part of ease.js. + * + * ease.js is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * @author Mike Gerwitz + * @package test + */ + +var common = require( './common' ), + mb_common = require( './inc-member_builder-common' ) +; + +mb_common.value = function() {}; +mb_common.buildMember = common.require( 'member_builder' ).buildMethod; + +// do assertions common to all member builders +mb_common.assertCommon(); +