public
Description: Prototype goodness
Clone URL: git://github.com/samleb/prototype-fruits.git
Search Repo:
Slight changes to class implementation
samleb (author)
Sun May 11 03:20:55 -0700 2008
commit  c218548a2f551a1a581710bb58c8aa286d735cab
tree    3c8885c6103770dd3e1b8dd3bf1211e1b1fb3a40
parent  832576aba7622f15cc6146c021b8570ef91e35db
...
14
15
16
17
 
18
19
20
...
56
57
58
59
60
 
61
62
63
 
 
64
65
66
...
14
15
16
 
17
18
19
20
...
56
57
58
 
 
59
60
 
 
61
62
63
64
65
0
@@ -14,7 +14,7 @@ var Concept = {
0
   },
0
 
0
   addMethods: function(source) {
0
- if (source instanceof Mixin)
0
+ if (Object.isFunction(window.Mixin) && source instanceof Mixin)
0
       return this.mixin(source);
0
     for (var property in source)
0
       this.addMethod(property, source[property]);
0
@@ -56,11 +56,10 @@ var Class = {
0
   }
0
 };
0
 
0
-var Mixin = function(){};
0
-Mixin = Class.create(Concept, (function() {
0
+var Mixin = Class.create(Concept, (function() {
0
   return {
0
- initialize: function(body) {
0
- this.prototype = body || { };
0
+ initialize: function(source) {
0
+ this.prototype = source || { };
0
       this.implementors = [ ];
0
     },
0
 
...
8
9
10
 
 
 
 
 
 
11
12
13
...
31
32
33
 
34
35
36
...
8
9
10
11
12
13
14
15
16
17
18
19
...
37
38
39
40
41
42
43
0
@@ -8,6 +8,12 @@ var ClassExtensions = {
0
     return this;
0
   },
0
   
0
+ wrapMethods: function(wrappers) {
0
+ Object.keys(wrappers).each(function(property) {
0
+ this.wrapMethod(property, wrappers[property]);
0
+ }, this);
0
+ },
0
+
0
   addOwnMethod: function(name, block) {
0
     this[name] = block;
0
     return this;
0
@@ -31,6 +37,7 @@ var ClassExtensions = {
0
   },
0
   
0
   ancestors: function() {
0
+ if (!this.superclass) return [ ];
0
     return [ this.superclass ].concat(this.superclass.ancestors());
0
   }
0
 };

Comments

    No one has commented yet.