From d9d9d82141d239d955f5414910b13f4fd98aed55 Mon Sep 17 00:00:00 2001 From: Raymond Feng Date: Fri, 20 Dec 2013 17:49:14 -0800 Subject: [PATCH] Add more comments --- lib/scope.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/scope.js b/lib/scope.js index 3094cc97..c1e6a51d 100644 --- a/lib/scope.js +++ b/lib/scope.js @@ -24,6 +24,17 @@ function defineScope(cls, targetClass, name, params, methods) { Object.defineProperty(cls, name, { enumerable: false, 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 () { var f = function caller(condOrRefresh, cb) { var actualCond = {}; @@ -84,7 +95,9 @@ function defineScope(cls, targetClass, name, params, methods) { // Wrap the property into a function for remoting var fn = function() { + // primaryObject.scopeName, such as user.accounts var f = this[name]; + // set receiver to be the scope property whose value is a function f.apply(this[name], arguments); };