forked from zaphar/joose-js-mirror
-
Notifications
You must be signed in to change notification settings - Fork 1
/
joose.js
3375 lines (2865 loc) · 99 KB
/
joose.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Generated: Sat Nov 15 12:20:31 2008
// ##########################
// File: Joose.js
// ##########################
var joosetop = this;
Joose = function () {
this.cc = null; // the current class
this.currentModule = null
this.top = joosetop;
this.globalObjects = [];
this.anonymouseClassCounter = 0;
};
// Static helpers for Arrays
Joose.A = {};
Joose.A.each = function (array, func) {
for(var i = 0; i < array.length; i++) {
func(array[i], i)
}
}
Joose.A.exists = function (array, value) {
for(var i = 0; i < array.length; i++) {
if(array[i] == value) {
return true
}
}
return false
}
Joose.A.concat = function (source, array) {
source.push.apply(source, array)
return source
}
Joose.A.grep = function (array, func) {
var a = [];
Joose.A.each(array, function (t) {
if(func(t)) {
a.push(t)
}
})
return a
}
Joose.A.remove = function (array, removeEle) {
var a = [];
Joose.A.each(array, function (t) {
if(t !== removeEle) {
a.push(t)
}
})
return a
}
// Static helpers for Strings
Joose.S = {};
Joose.S.uppercaseFirst = function (string) {
var first = string.substr(0,1);
var rest = string.substr(1,string.length-1);
first = first.toUpperCase()
return first + rest;
}
Joose.S.isString = function (thing) {
if(typeof thing == "string") {
return true
}
return false
}
// Static helpers for objects
Joose.O = {};
Joose.O.each = function (object, func) {
for(var i in object) {
func(object[i], i)
}
}
Joose.O.eachSafe = function (object, func) {
for(var i in object) {
if(object.hasOwnProperty(i)) {
func(object[i], i)
}
}
}
// Experimental!
Joose.O.extend = function (target, newObject) {
for(var i in newObject) {
var thing = newObject[i]
target[i] = thing
}
}
Joose.prototype = {
addToString: function (object, func) {
object.toString = func;
},
/*
* Differentiates between instances and classes
*/
isInstance: function(obj) {
if(!obj.meta) {
throw "isInstance only works with Joose objects and classes."
}
if(obj.constructor === obj.meta.c) {
return true
}
return false
},
init: function () {
this.builder = new Joose.Builder();
this.builder.globalize()
},
// this needs to be updated in release.pl too, if files are added
components: function () {
return [
"Joose.Builder",
"Joose.Class",
"Joose.Method",
"Joose.ClassMethod",
"Joose.Attribute",
"Joose.Role",
"Joose.SimpleRequest",
"Joose.Gears",
"Joose.Storage",
"Joose.Storage.Unpacker",
"Joose.Decorator",
"Joose.Module",
"Joose.Prototype",
"Joose.TypeConstraint",
"Joose.TypeCoercion",
"Joose.Types"
]
},
loadComponents: function (basePath) {
var html = "";
Joose.A.each(this.components(), function (name) {
var url = ""+basePath + "/" + name.split(".").join("/") + ".js";
html += '<script type="text/javascript" src="'+url+'"></script>'
})
document.write(html)
}
}
Joose.copyObject = function (source, target) {
var keys = "";
Joose.O.each(source, function (value, name) { keys+=", "+name; target[name] = value })
return target
};
Joose.emptyFunction = function () {};
var joose = new Joose();
Joose.bootstrap = function () {
// Bootstrap
var BOOT = new Joose.MetaClassBootstrap();
BOOT.builder = Joose.MetaClassBootstrap;
Joose.MetaClass = BOOT.createClass("Joose.MetaClass");
Joose.MetaClass.meta.addNonJooseSuperClass("Joose.MetaClassBootstrap", BOOT)
Joose.MetaClass.meta.addMethod("initialize", function () { this._name = "Joose.MetaClass" })
var META = new Joose.MetaClass();
META.builder = Joose.MetaClass;
Joose.Class = META.createClass("Joose.Class")
Joose.Class.meta.addSuperClass(Joose.MetaClass);
Joose.MetaClass.meta.addMethod("initialize", function () { this._name = "Joose.Class" })
}
Joose.bootstrap2 = function () {
// Turn Joose.Method into a Joose.Class object
Joose.Builder.Globals.joosify("Joose.Method", Joose.Method)
Joose.Builder.Globals.joosify("Joose.Attribute", Joose.Attribute)
}
Joose.bootstrap3 = function () {
// make the .meta object circular
}
/**
* @name Joose.Class
* @constructor
*/
/*
* Joose.MetaClassBootstrap is used to bootstrap the Joose.Class with a regular JS constructor
*/
/** ignore */ // Do not display the Bootstrap classes in the docs
Joose.MetaClassBootstrap = function () {
this._name = "Joose.MetaClassBootstrap";
this.methodNames = [];
this.attributeNames = ["_name", "isAbstract", "isDetached", "methodNames", "attributeNames", "methods", "parentClasses", "roles", "c"];
this.attributes = {},
this.methods = {};
this.classMethods = {};
this.parentClasses = [];
this.roles = []; // All roles
this.myRoles = []; // Only roles applied to me directly
this.isAbstract = false;
this.isDetached = false;
}
/** @ignore */
Joose.MetaClassBootstrap.prototype = {
toString: function () {
if(this.meta) {
return "a "+this.meta.className();
}
return "NoMeta"
},
/**
* Returns the name of the class
* @name className
* @function
* @memberof Joose.Class
*/
/** @ignore */
className: function () {
return this._name
},
/**
* Returns the name of the class (alias to className())
* @name getName
* @function
* @memberof Joose.Class
*/
/** @ignore */
getName: function () {
return this.className()
},
/**
* Creates a new empty meta class object
* @function
* @name newMetaClass
* @memberof Joose.Class
*/
/** @ignore */
newMetaClass: function () {
var me = this;
var metaClassClass = this.builder;
var c = new metaClassClass();
c.builder = metaClassClass;
c._name = this._name
c.methodNames = [];
c.attributeNames = [];
c.methods = {};
c.classMethods = {};
c.parentClasses = [];
c.roles = [];
c.myRoles = [];
c.attributes = {};
var myMeta = this.meta;
if(!myMeta) {
myMeta = this;
}
c.meta = myMeta
return c
},
/**
* Creates a new class object
* @function
* @name createClass
* @param {function} optionalConstructor If provided will be used as the class constructor (You should not need this)
* @param {Joose.Module} optionalModuleObject If provided the Module's name will be prepended to the class name
* @memberof Joose.Class
*/
/** @ignore */
createClass: function (name, optionalConstructor, optionalModuleObject) {
var meta = this.newMetaClass();
var c;
if(optionalConstructor) {
c = optionalConstructor
} else {
c = this.defaultClassFunctionBody()
if(optionalModuleObject) {
optionalModuleObject.addElement(c)
// meta.setModule(optionalModuleObject)
}
}
c.prototype.meta = meta
c.meta = meta;
if(name == null) {
meta._name = "__anonymous__"
} else {
var className = name;
if(optionalModuleObject) {
className = optionalModuleObject.getName() + "." + name
}
meta._name = className;
}
meta.c = c;
// store them in the global object if they have no namespace
// They will end up in the Module __JOOSE_GLOBAL__
if(!optionalModuleObject) {
// Because the class Joose.Module might not exist yet, we use this temp store
// that will later be in the global module
joose.globalObjects.push(c)
}
meta.addInitializer();
meta.addToString();
meta.addDetacher();
return c;
},
buildComplete: function () {
// may be overriden in sublass
},
// intializes a class from the class definitions
initializeFromProps: function (props) {
this._initializeFromProps(props)
},
_initializeFromProps: function (props) {
var me = this;
if(props) {
// For each property of the class constructor call the builder
Joose.O.eachSafe(props, function (value, name) {
var paras = value;
var customBuilderName = "handleProp"+name;
// if the meta class of the current class implements handleProp+nameOfBuilder we use that
if(me.meta.can(customBuilderName)) {
me[customBuilderName](paras, props)
} else { // Otherwise use a builder from this file
throw new Error("Called invalid builder "+name+" while creating class "+me.className())
}
})
for(var i = 0; i < this.roles.length; i++) {
var role = this.roles[i];
role.meta.applyMethodModifiers(this.c)
}
me.buildComplete()
me.validateClass()
}
},
/**
* Returns a new instance of the class that this meta class instance is representing
* @function
* @name instantiate
* @memberof Joose.Class
*/
instantiate: function () {
//var o = new this.c.apply(this, arguments);
// Ough! Calling a constructor with arbitrary arguments hack
var f = function () {};
f.prototype = this.c.prototype;
f.prototype.constructor = this.c;
var obj = new f();
this.c.apply(obj, arguments);
return obj;
},
/**
* Returns the default constructor function for new classes. You might want to override this in derived meta classes
* Default calls initialize on a new object upon construction.
* The class object will stringify to it's name
* @function
* @name defaultClassFunctionBody
* @memberof Joose.Class
*/
/** @ignore */
defaultClassFunctionBody: function () {
var f = function () {
this.initialize.apply(this, arguments);
};
joose.addToString(f, function () {
return this.meta.className()
})
return f;
},
/**
* Adds a toString method to a class
* The default toString method will call the method stringify if available.
* This make overriding stringification easier because toString cannot
* be reliably overriden in some JS implementations.
* @function
* @name addToString
* @memberof Joose.Class
*/
/** @ignore */
addToString: function () {
this.addMethod("toString", function () {
if(this.stringify) {
return this.stringify()
}
return "a "+ this.meta.className()
})
},
/**
* Adds the method returned by the initializer method to the class
* @function
* @name addInitializer
* @memberof Joose.Class
*/
/** @ignore */
addInitializer: function () {
if(!this.c.prototype.initialize) {
this.addMethod("initialize", this.initializer())
}
},
/**
* Adds a toString method to a class
* @function
* @name initializer
* @memberof Joose.Class
*/
/** @ignore */
initializer: function () {
return function initialize (paras) {
var me = this;
if(this.meta.isAbstract) {
var name = this.meta.className();
throw ""+name+" is an abstract class and may not instantiated."
}
var attributes = this.meta.getAttributes();
for(var i in attributes) {
if(attributes.hasOwnProperty(i)) {
var attr = attributes[i];
attr.doInitialization(me, paras);
}
}
}
},
dieIfString: function (thing) {
if(Joose.S.isString(thing)) {
throw new TypeError("Parameter must not be a string.")
}
},
addRole: function (roleClass) {
this.dieIfString(roleClass);
var c = this.getClassObject();
if(roleClass.meta.apply(c)) {
this.roles.push(roleClass);
this.myRoles.push(roleClass);
}
},
getClassObject: function () {
return this.c
},
classNameToClassObject: function (className) {
var top = joose.top;
var parts = className.split(".");
var object = top;
for(var i = 0; i < parts.length; i++) {
var part = parts[i];
object = object[part];
if(!object) {
throw "Unable to find class "+className
}
}
return object
},
addNonJooseSuperClass: function (name, object) {
var pseudoMeta = new Joose.MetaClassBootstrap();
pseudoMeta.builder = Joose.MetaClassBootstrap;
var pseudoClass = pseudoMeta.createClass(name)
Joose.O.each(object, function(value, name) {
if(typeof(value) == "function") {
pseudoClass.meta.addMethod(name, value)
} else {
pseudoClass.meta.addAttribute(name, {init: value})
}
})
this.addSuperClass(pseudoClass);
},
addSuperClass: function (classObject) {
this.dieIfString(classObject);
var me = this;
//this._fixMetaclassIncompatability(classObject)
// Methods
var names = classObject.meta.getMethodNames();
for(var i = 0; i < names.length; i++) {
var name = names[i]
var m = classObject.meta.getMethodObject(name)
if(m) {
var method = m.copy();
method.setIsFromSuperClass(true);
me.addMethodObject(method)
}
m = classObject.meta.getClassMethodObject(name)
if(m) {
var method = m.copy();
method.setIsFromSuperClass(true);
me.addMethodObject(method)
}
}
// Attributes
Joose.O.eachSafe(classObject.meta.attributes, function (attr, name) {
me.addAttribute(name, attr.getProps())
})
// Roles
var roles = classObject.meta.roles
for(var i = 0; i < roles.length; i++) {
var role = roles[i]
me.roles.push(role)
}
this.parentClasses.unshift(classObject)
},
_fixMetaclassIncompatability: function (superClass) {
var superMeta = superClass.meta;
var superMetaName = superMeta.meta.className();
if(
superMetaName == "Joose.Class" ||
superMetaName == "Joose.MetaClass" ||
superMetaName == "Joose.MetaClassBootstrap") {
return
}
// we are compatible
if(this.meta.meta.isa(superMeta)) {
return
}
// fix this into becoming a superMeta
var patched = superMeta.meta.instantiate(this);
for(var i in patched) {
this[i] = patched[i]
}
},
isa: function (classObject) {
this.dieIfString(classObject);
var name = classObject.meta.className()
// Same type
if(this.className() == name) {
return true
}
// Look up into parent classes
for(var i = 0; i < this.parentClasses.length; i++) {
var parent = this.parentClasses[i].meta
if(parent.className() == name) {
return true
}
if(parent.isa(classObject)) {
return true
}
}
return false
},
wrapMethod: function (name, wrappingStyle, func, notPresentCB) {
var orig = this.getMethodObject(name);
if(orig) {
this.addMethodObject( orig[wrappingStyle](func) )
} else {
if(notPresentCB) {
notPresentCB()
} else {
throw new Error("Unable to apply "+wrappingStyle+" method modifier because method "+name+" does not exist");
}
}
},
dispatch: function (name) {
return this.getMethodObject(name).asFunction()
},
hasMethod: function (name) {
return this.methods[name] != null || this.classMethods[name] != null
},
addMethod: function (name, func, props) {
var m = new Joose.Method(name, func, props);
this.addMethodObject(m)
},
addClassMethod: function (name, func, props) {
var m = new Joose.ClassMethod(name, func, props);
this.addMethodObject(m)
},
addMethodObject: function (method) {
var m = method;
var name = m.getName();
if(!this.methods[name] && !this.classMethods[name]) {
this.methodNames.push(name);
}
if(m.isClassMethod()) {
this.classMethods[name] = m;
} else {
this.methods[name] = m;
}
method.addToClass(this.c)
},
attributeMetaclass: function () {
return Joose.Attribute
},
addAttribute: function (name, props) {
var metaclass = this.attributeMetaclass();
if(props && props.metaclass) {
metaclass = props.metaclass
}
var at = new metaclass(name, props);
at.apply(this.c)
},
getAttributes: function () {
return this.attributes
},
getAttribute: function (name) {
return this.attributes[name]
},
setAttribute: function (name, attributeObject) {
return this.attributes[name] = attributeObject
},
getMethodObject: function (name) {
return this.methods[name]
},
getClassMethodObject: function (name) {
return this.classMethods[name]
},
getAttributeNames: function () {
return this.attributeNames;
},
getInstanceMethods: function () {
var a = [];
Joose.O.eachSafe(this.methods, function (m) {
a.push(m)
})
return a
},
getClassMethods: function () {
var a = [];
Joose.O.eachSafe(this.classMethods, function (m) {
a.push(m)
})
return a
},
getSuperClasses: function () {
return this.parentClasses;
},
getSuperClass: function () {
return this.parentClasses[0];
},
getRoles: function () {
return this.roles;
},
getMethodNames: function () {
return this.methodNames;
},
makeAnonSubclass: function () {
var c = this.createClass(this.className()+"__anon__"+joose.anonymouseClassCounter++);
c.meta.addSuperClass(this.getClassObject());
return c;
},
addDetacher: function () {
this.addMethod("detach", function detach () {
var meta = this.meta;
if(meta.isDetached) {
return // no reason to do it again
}
var c = meta.makeAnonSubclass()
c.meta.isDetached = true;
// appy the role to the anonymous class
// swap meta class of object with new instance
this.meta = c.meta;
// swap __proto__ chain of object to its new class
// unfortunately this is not available in IE :(
// object.__proto__ = c.prototype
this.constructor = c;
var proto;
// Workaround for IE and opera to enable prototype extention via the meta class (by making them identical :)
// This however makes Role.unapply impossible
if(!this.__proto__) {
proto = this
} else {
proto = {};
Joose.copyObject(this, proto)
}
c.prototype = proto;
this.__proto__ = c.prototype
return
})
},
/**
* Throws an exception if the class does not implement all methods required by it's roles
* @function
* @name validateClass
* @memberof Joose.Class
*/
validateClass: function () {
var c = this.getClassObject();
var me = this;
// Test whether all rows are fully implemented.
var throwException = true;
Joose.A.each(this.roles, function(role) {
role.meta.isImplementedBy(c, throwException)
})
},
/**
* Returns true if the class implements the method
* @function
* @name can
* @param {string} methodName The method
* @memberof Joose.Class
*/
can: function (methodName) {
var method = this.methods[methodName];
if(!method) {
return false
}
return true
},
classCan: function (methodName) {
var method = this.classMethods[methodName];
if(!method) {
return false
}
return true
},
/**
* Returns true if the class implements a Role
* @function
* @name does
* @param {Joose.Class} methodName The class object
* @memberof Joose.Class
*/
does: function (roleObject) {
for(var i = 0; i < this.roles.length; i++) {
if(roleObject === this.roles[i]) {
return true
}
}
// dive into roles to find roles implemented by my roles
for(var i = 0; i < this.roles.length; i++) {
if(this.roles[i].meta.does(roleObject)) {
return true
}
}
return false
// return classObject.meta.implementsMyMethods(this.getClassObject())
},
/**
* Returns true if the given class implements all methods of the class
* @function
* @name does
* @param {Joose.Class} methodName The class object
* @memberof Joose.Class
*/
implementsMyMethods: function (classObject) {
var complete = true
// FIXME buggy if class methods are involved. Should roles have class methods?
Joose.A.each(this.getMethodNames(), function (value) {
var found = classObject.meta.can(value)
if(!found) {
complete = false
}
})
return complete
},
// Class builders:
/**
* Tells a role that the method name must be implemented by all classes that implement the role
* @function
* @param methodName {string} Name of the required method name
* @name requires
* @memberof Joose.Builder
*/
/** @ignore */
handleProprequires: function (methodName) {
var me = this;
if(!this.meta.isa(Joose.Role)) {
throw("Keyword 'requires' only available classes with a meta class of type Joose.Role")
}
if(methodName instanceof Array) {
Joose.A.each(methodName, function (name) {
me.addRequirement(name)
})
} else {
me.addRequirement(methodName)
}
},
handlePropisAbstract: function (bool) {
this.isAbstract = bool
},
/**
* Class builder method
* Defines the super class of the class
* @function
* @param classObject {Joose.Class} The super class
* @name isa
* @memberof Joose.Builder
*/
/** @ignore */
handlePropisa: function (classObject) {
this.addSuperClass(classObject)
},
/**
* Class builder method
* Defines a role for the class
* @function
* @param classObject {Joose.Role} The role
* @name does
* @memberof Joose.Builder
*/
/** @ignore */
handlePropdoes: function (role) {
var me = this;
if(role instanceof Array) {
Joose.A.each(role, function (aRole) {
me.addRole(aRole)
})
} else {
me.addRole(role)
}
},
/**
* Class builder method
* Defines attributes for the class
* @function
* @param classObject {object} Maps attribute names to properties (See Joose.Attribute)
* @name has
* @memberof Joose.Builder
*/
/** @ignore */
handleProphas: function (map) {
var me = this;
if(typeof map == "string") {
var name = arguments[0];
var props = arguments[1];
me.addAttribute(name, props)
} else { // name is a map
Joose.O.eachSafe(map, function (props, name) {
me.addAttribute(name, props)
})
}
},
/**
* @ignore
*/
handlePropmethod: function (name, func, props) {
this.addMethod(name, func, props)
},
/**
* Class builder method
* Defines methods for the class
* @function
* @param classObject {object} Maps method names to function bodies
* @name methods
* @memberof Joose.Builder
*/
/** @ignore */
handlePropmethods: function (map) {
var me = this
Joose.O.eachSafe(map, function (func, name) {
me.addMethod(name, func)
})
},
/**
* Class builder method
* Defines class methods for the class
* @function
* @param classObject {object} Maps class method names to function bodies
* @name classMethods
* @memberof Joose.Builder
*/
/** @ignore */
handlePropclassMethods: function (map) {
var me = this;
Joose.O.eachSafe(map, function (func, name2) {
me.addMethodObject(new Joose.ClassMethod(name2, func))
})
},
/**
* Class builder method
* Defines workers for the class (The class must have the meta class Joose.Gears)
* @function
* @param classObject {object} Maps method names to function bodies
* @name workers
* @memberof Joose.Builder
*/
/** @ignore */
handlePropworkers: function (map) {
var me = this;
Joose.O.eachSafe(map, function (func, name) {
me.addWorker(name, func)
})
},
/**
* Class builder method
* Defines before method modifieres for the class.