/** 
 * Handy shortcut to create properties.
 * @author Ariel Flesler
 */

/**
 * Ways to specify the list of properties:
 *	@example { properties: 'name, age, gender' }
 *	@desc A comma separated list of names. The private attribute needs to have that name.
 *
 *	@example { properties: ['name', 'age', 'gender'] }
 *	@desc An array of names. The private attribute needs to have that name.
 *
 *	@example { properties: { name:'_name', age:'_age' } }
 *	@desc A map where keys=public names and values=name of private attribute.
 *
 *	@example { properties: { name:fnName, age: fnAge } }
 *	@desc A map where keys=public names and values=function that handles the setting/getting.
 */

Class.extensions( 'properties', function( data, list ){
	if( list.split )
		list = list.split(/, ?/);
		
	if( list.constructor == Array )
		for( var i = list.length; i--; )
			create( list[i] );
	else
		for( var key in list )
			create( key, list[key] );
	
	function create( prop, member ){
		member = member || prop;
		var Prop = prop.charAt(0).toUpperCase() + prop.slice(1);
		data.m[Prop] = function( value ){
			if( typeof member == 'function' )
				return member.call( this, value, prop );
			if( arguments.length )
				this[member] = value;
			return this[member];
		};
	};
});