js/data/DataSource.js
function (entity, action, options) {
                var ret = {},
                    data = entity.compose(action, options),
                    schemaDefinition,
                    schemaType,
                    isModel = entity instanceof Model,
                    factory = entity.factory;

                for (var key in entity.schema) {
                    if (entity.schema.hasOwnProperty(key) && (!isModel || (!options || !options.includeInIndex || _.contains(options.includeInIndex, key)))) {
                        schemaDefinition = entity.schema[key];
                        schemaType = schemaDefinition.type;


                        var value;
                        if (data[key] && schemaDefinition.isReference && schemaType.classof && schemaType.classof(Entity) && !schemaType.classof(Model)) {
                            value = {};
                            value[schemaType.prototype.idField] = data[key].identifier();
                        } else {
                            value = this._getCompositionValue(data[key], key, action, options, entity);
                        }
                        if (value !== undefined) {
                            ret[this._getReferenceKey(key, schemaType)] = value;
                        }
                    }
                }
                return ret;
            }
function (entity, action, options) {
                var ret = {},
                    data = entity.compose(action, options),
                    schemaDefinition,
                    schemaType,
                    isModel = entity instanceof Model,
                    factory = entity.factory;

                for (var key in entity.schema) {
                    if (entity.schema.hasOwnProperty(key) && (!isModel || (!options || !options.includeInIndex || _.contains(options.includeInIndex, key)))) {
                        schemaDefinition = entity.schema[key];
                        schemaType = schemaDefinition.type;


                        var value;
                        if (data[key] && schemaDefinition.isReference && schemaType.classof && schemaType.classof(Entity) && !schemaType.classof(Model)) {
                            value = {};
                            value[schemaType.prototype.idField] = data[key].identifier();
                        } else {
                            value = this._getCompositionValue(data[key], key, action, options, entity);
                        }
                        if (value !== undefined) {
                            ret[this._getReferenceKey(key, schemaType)] = value;
                        }
                    }
                }
                return ret;
            }
function ( entity , action , options ) { var ret = { } , data = entity . compose ( action , options ) , schemaDefinition , schemaType , isModel = entity instanceof Model , factory = entity . factory ; for ( var key in entity . schema ) { if ( entity . schema . hasOwnProperty ( key ) && ( ! isModel || ( ! options || ! options . includeInIndex || _ . contains ( options . includeInIndex , key ) ) ) ) { schemaDefinition = entity . schema [ key ] ; schemaType = schemaDefinition . type ; var value ; if ( data [ key ] && schemaDefinition . isReference && schemaType . classof && schemaType . classof ( Entity ) && ! schemaType . classof ( Model ) ) { value = { } ; value [ schemaType . prototype . idField ] = data [ key ] . identifier ( ) ; } else { value = this . _getCompositionValue ( data [ key ] , key , action , options , entity ) ; } if ( value !== undefined ) { ret [ this . _getReferenceKey ( key , schemaType ) ] = value ; } } } return ret ; }
Composes an entity, calls default compose method
@param entity
@param action
@param options
@return {JSON}
@private
Composes an entity calls default compose method