@@ -1226,7 +1226,7 @@ module.exports = function(AV) {
12261226 } ;
12271227 /**
12281228 * Delete objects in batch.The objects className must be the same.
1229- * @param {Array } The <code>AV.Object</code> array to be deleted.
1229+ * @param {AV.Object[] } objects The <code>AV.Object</code> array to be deleted.
12301230 * @param {AuthOptions } options
12311231 * @return {Promise } A promise that is fulfilled when the save
12321232 * completes.
@@ -1385,7 +1385,7 @@ module.exports = function(AV) {
13851385 // ES6 class syntax support
13861386 Object . defineProperty ( AV . Object . prototype , 'className' , {
13871387 get : function ( ) {
1388- const className = this . _className || this . constructor . name ;
1388+ const className = this . _className || this . constructor . _LCClassName || this . constructor . name ;
13891389 // If someone tries to subclass "User", coerce it to the right type.
13901390 if ( className === "User" ) {
13911391 return "_User" ;
@@ -1394,14 +1394,27 @@ module.exports = function(AV) {
13941394 } ,
13951395 } ) ;
13961396
1397- AV . Object . register = klass => {
1397+ /**
1398+ * Register a class.
1399+ * If a subclass of <code>AV.Object</code> is defined with your own implement
1400+ * rather then <code>AV.Object.extend</code>, the subclass must be registered.
1401+ * @param {Function } klass A subclass of <code>AV.Object</code>
1402+ * @param {String } [name] Specify the name of the class. Useful when the class might be uglified.
1403+ * @example
1404+ * class Person extend AV.Object {}
1405+ * AV.Object.register(Person);
1406+ */
1407+ AV . Object . register = ( klass , name ) => {
13981408 if ( ! ( klass . prototype instanceof AV . Object ) ) {
13991409 throw new Error ( 'registered class is not a subclass of AV.Object' ) ;
14001410 }
1401- const className = klass . name ;
1411+ const className = name || klass . name ;
14021412 if ( ! className . length ) {
14031413 throw new Error ( 'registered class must be named' ) ;
14041414 }
1415+ if ( name ) {
1416+ klass . _LCClassName = name ;
1417+ }
14051418 AV . Object . _classMap [ className ] = klass ;
14061419 } ;
14071420
0 commit comments