argon/association.js
function hasMany(config) {
        var association;
        association = {
            type           : 'HAS_MANY',
            name           : config.name || config,
            cardinality    : 'many',
            targetModel    : config.targetModel || config,
            localProperty  : config.localProperty || 'id',
            targetProperty : config.targetProperty || (config + 'Id')
        };
        
        this.prototype[association.name] = function(callback){
            var model = this;
            var targetModel = window;
            association.targetModel.split('.').forEach(function (property) {
                targetModel = targetModel[property];
            });
            targetModel.all(function (data) {
                var result = data.filter(function (instance) {
                    return instance[association.targetProperty] === model[association.localProperty];
                });
                if (callback) {
                    callback(result);
                }
            });
        };
        
        return this;
    }
function hasMany(config) {
        var association;
        association = {
            type           : 'HAS_MANY',
            name           : config.name || config,
            cardinality    : 'many',
            targetModel    : config.targetModel || config,
            localProperty  : config.localProperty || 'id',
            targetProperty : config.targetProperty || (config + 'Id')
        };
        
        this.prototype[association.name] = function(callback){
            var model = this;
            var targetModel = window;
            association.targetModel.split('.').forEach(function (property) {
                targetModel = targetModel[property];
            });
            targetModel.all(function (data) {
                var result = data.filter(function (instance) {
                    return instance[association.targetProperty] === model[association.localProperty];
                });
                if (callback) {
                    callback(result);
                }
            });
        };
        
        return this;
    }
function hasMany ( config ) { var association ; association = { type : 'HAS_MANY' , name : config . name || config , cardinality : 'many' , targetModel : config . targetModel || config , localProperty : config . localProperty || 'id' , targetProperty : config . targetProperty || ( config + 'Id' ) } ; this . prototype [ association . name ] = function ( callback ) { var model = this ; var targetModel = window ; association . targetModel . split ( '.' ) . forEach ( function ( property ) { targetModel = targetModel [ property ] ; } ) ; targetModel . all ( function ( data ) { var result = data . filter ( function ( instance ) { return instance [ association . targetProperty ] === model [ association . localProperty ] ; } ) ; if ( callback ) { callback ( result ) ; } } ) ; } ; return this ; }
Creates a hasMany method on the class running the method, this creates the "associationName"
method on the object running the method. This is a factory method
@method <public> hasMany
@argument <required> [Object] ({}) config
@return this
Creates a hasMany method on the class running the method this creates the associationName method on the object running the method . This is a factory method