Add more comments

This commit is contained in:
Raymond Feng 2013-12-20 17:49:14 -08:00
parent f1773857bb
commit d9d9d82141
1 changed files with 13 additions and 0 deletions

View File

@ -24,6 +24,17 @@ function defineScope(cls, targetClass, name, params, methods) {
Object.defineProperty(cls, name, { Object.defineProperty(cls, name, {
enumerable: false, enumerable: false,
configurable: true, configurable: true,
/**
* This defines a property for the scope. For example, user.accounts or
* User.vips. Please note the cls can be the model class or prototype of
* the model class.
*
* The property value is function. It can be used to query the scope,
* such as user.accounts(condOrRefresh, cb) or User.vips(cb). The value
* can also have child properties for create/build/delete. For example,
* user.accounts.create(act, cb).
*
*/
get: function () { get: function () {
var f = function caller(condOrRefresh, cb) { var f = function caller(condOrRefresh, cb) {
var actualCond = {}; var actualCond = {};
@ -84,7 +95,9 @@ function defineScope(cls, targetClass, name, params, methods) {
// Wrap the property into a function for remoting // Wrap the property into a function for remoting
var fn = function() { var fn = function() {
// primaryObject.scopeName, such as user.accounts
var f = this[name]; var f = this[name];
// set receiver to be the scope property whose value is a function
f.apply(this[name], arguments); f.apply(this[name], arguments);
}; };