src/model.js
function Property (name, value, parent, metadata) {

        var myName = "/" + name;
        if (parent) {
            myName = parent.getName() + myName;
        }

        Object.defineProperty(this, "_name", {
            value: myName,
            enumerable: false
        });

        Object.defineProperty(this, "_parent", {
            value: parent,
            enumerable: false,
            writable: false,
            configurable: true //set to configurable so we can delete it in destroy
        });

        Object.defineProperty(this, "_metadata", {
            value: metadata || {},
            enumerable: false
        });

        Object.defineProperty(this, "_eventListeners", {
            value: { //map of eventName to listener array. The following are modeljs Events
                propertyChange: [],
                modelChange: [],
                change: [],
                childCreated: [],
                childDestroyed: [],
                destroy: [],
                all: []
            },
            enumerable: false,
            writable: false,
            configurable: false
        });

        var myValue = value;
        if (isFunction(myValue)) {
            myValue = myValue.bind(parent);
        }
        //make sure value is valid
        if (!this.validateValue(myValue)) {
            myValue = undefined;
        }

        Object.defineProperty(this, "_myValue", {
            value: myValue,
            enumerable: false,
            writable: true
        });
    }
function Property (name, value, parent, metadata) {

        var myName = "/" + name;
        if (parent) {
            myName = parent.getName() + myName;
        }

        Object.defineProperty(this, "_name", {
            value: myName,
            enumerable: false
        });

        Object.defineProperty(this, "_parent", {
            value: parent,
            enumerable: false,
            writable: false,
            configurable: true //set to configurable so we can delete it in destroy
        });

        Object.defineProperty(this, "_metadata", {
            value: metadata || {},
            enumerable: false
        });

        Object.defineProperty(this, "_eventListeners", {
            value: { //map of eventName to listener array. The following are modeljs Events
                propertyChange: [],
                modelChange: [],
                change: [],
                childCreated: [],
                childDestroyed: [],
                destroy: [],
                all: []
            },
            enumerable: false,
            writable: false,
            configurable: false
        });

        var myValue = value;
        if (isFunction(myValue)) {
            myValue = myValue.bind(parent);
        }
        //make sure value is valid
        if (!this.validateValue(myValue)) {
            myValue = undefined;
        }

        Object.defineProperty(this, "_myValue", {
            value: myValue,
            enumerable: false,
            writable: true
        });
    }
function Property ( name , value , parent , metadata ) { var myName = "/" + name ; if ( parent ) { myName = parent . getName ( ) + myName ; } Object . defineProperty ( this , "_name" , { value : myName , enumerable : false } ) ; Object . defineProperty ( this , "_parent" , { value : parent , enumerable : false , writable : false , configurable : true //set to configurable so we can delete it in destroy
 } ) ; Object . defineProperty ( this , "_metadata" , { value : metadata || { } , enumerable : false } ) ; Object . defineProperty ( this , "_eventListeners" , { value : { //map of eventName to listener array. The following are modeljs Events
 propertyChange : [ ] , modelChange : [ ] , change : [ ] , childCreated : [ ] , childDestroyed : [ ] , destroy : [ ] , all : [ ] } , enumerable : false , writable : false , configurable : false } ) ; var myValue = value ; if ( isFunction ( myValue ) ) { myValue = myValue . bind ( parent ) ; } //make sure value is valid
 if ( ! this . validateValue ( myValue ) ) { myValue = undefined ; } Object . defineProperty ( this , "_myValue" , { value : myValue , enumerable : false , writable : true } ) ; }
A Property is a name value pair belonging to a Model.

@class Property
@constructor
@private used internally by the Model.prototype.createProperty method.

@param {[String]} name    The name of the property
@param {[String, Boolean, Number, null, Date, Function, Object]} value   The Property Value
@param {[Model]} parent  The parent property
@param {[Object]} metadata The metadata associated with the property. You can put any metadata you want. However the following keys have special meaning and are reserved for use by the framework.
validator - a function to validate if the new value is valid before it is assigned.
url - the resource this model should use to get it's value. Resource must return json. *Must be used with refreshRate*
refreshRate - the interval used to query the url for changes. must be > 0. minimal value used is 100. -1 indicates to only fetch value once. *Must be used with url*
A Property is a name value pair belonging to a Model .