
var Proteus = require("proteus"),
    IGNORE_METHODS = Proteus.enumerate("init", "attach"),
    Behavior
;
//---------------------------------------------------------------------------
// Privates // Short-cuts
//---------------------------------------------------------------------------
/**
 * @function makeProxy
 * @param {Object} behavior the behavior we are proxying
 * @param {Object} dice the dice object
 * @param {String} aspect the particular method/property we are proxying
 */
function makeProxy (dice, name) {
    var self, OP, ObjValueOf, ObjToString,
        selfSpec, selfGetter, selfSetter, selfValue, isFn, isObjProto,
        diceSpec, diceGetter, diceSetter, diceValue, proxy
    ;
    
    if (IGNORE_METHODS[name]) {
        return;
    }
    
    self        = this;
    OP          = Object.prototype;
    ObjValueOf  = OP.valueOf;
    ObjToString = OP.toString;
    selfSpec    = Proteus.getPropertyDescriptor(this, name);
    selfGetter  = selfSpec.get;
    selfSetter  = selfSpec.set;
    selfValue   = selfSpec.value;
    isFn        = typeof selfValue === "function";
    isObjProto  = selfValue === ObjValueOf || selfValue === ObjToString;
    
    if (selfGetter || selfSetter || (isFn && !isObjProto)) {
        diceSpec   = Proteus.getPropertyDescriptor(dice, name) || {};
        diceGetter = diceSpec.get;
        diceSetter = diceSpec.set;
        diceValue  = diceValue;
        
        proxy = function () {
            // console.log(aspect);
            var fn     = (arguments.length > 0 ? diceSetter : diceGetter) || diceValue,
                result = fn && fn.apply(dice, arguments),
                args   = [dice, result],
                ret    = self[name].apply(self, args)
            ;

            return ret === undefined ? result : ret;
        };

        if (diceGetter || diceSetter) {
            diceSpec.get = diceSpec.set = proxy;
        }
        else {
            diceSpec.value = proxy;
        }

        // console.log(aspect, spec);
        Object.defineProperty(dice, name, diceSpec);
    }
}
//---------------------------------------------------------------------------
// Exports
//---------------------------------------------------------------------------
module.exports = Behavior = Proteus.Class.derive({
    
    self: Object.defineProperties({
        
        initialize: function (instance, args) {
            // if behavior is undefined, the normal instantiation of behavior takes place
            return this.find(args[0]);
        },
        
        get: function (name) {
            var behavior = this.__behaviors__[name] || this.find(name);
            
            if (!behavior) {
                throw "Unknown behavior '" + name + "'";
            }
            
            return behavior;
        },
        
        find: function (name) {
            var behaviors = this.__behaviors__,
                behavior
            ;
            
            Object.keys(behaviors).some(function (key) {
                var obj = behaviors[key],
                    abbrev = obj.abbreviation
                ;
                
                if (key === name || abbrev === name) {
                    behavior = obj;
                    return true;
                }
            });
            
            return behavior;
        }
        
    }, {
        __behaviors__: { value: {} }
    }),
    
    init: function (name, props) {
        Proteus.merge(this, props);
        Behavior.__behaviors__[name] = this;
    },
    
    attach: function (dice) {
        Proteus.getPropertyNames(this).forEach(makeProxy.bind(this, dice));
    }
    
});

@@ -3463,16 +3463,42 @@
 props);%0A
+        this.name = name;%0A
         

Make sure to set the behavior's name.