Permalink
Browse files

idioms

  • Loading branch information...
1 parent dc8b1ba commit 42e9d0dccc60932129f454c1d5217934baf31cbc @mcandre mcandre committed Apr 5, 2013
Showing with 18 additions and 16 deletions.
  1. +18 −16 lib/class.js
View
@@ -18,27 +18,29 @@ Class.extend = function(prop) {
var prototype = new this();
initializing = false;
+ var f = function(name, fn) {
+ return function() {
+ var tmp = this._super;
+
+ // Add a new ._super() method that is the same method
+ // but on the super-class
+ this._super = _super[name];
+
+ // The method only need to be bound temporarily, so we
+ // remove it when we're done executing
+ var ret = fn.apply(this, arguments);
+ this._super = tmp;
+
+ return ret;
+ };
+ });
+
// Copy the properties over onto the new prototype
for (var name in prop) {
// Check if we're overwriting an existing function
prototype[name] = typeof prop[name] == "function" &&
typeof _super[name] == "function" && fnTest.test(prop[name]) ?
- (function(name, fn){
- return function() {
- var tmp = this._super;
-
- // Add a new ._super() method that is the same method
- // but on the super-class
- this._super = _super[name];
-
- // The method only need to be bound temporarily, so we
- // remove it when we're done executing
- var ret = fn.apply(this, arguments);
- this._super = tmp;
-
- return ret;
- };
- })(name, prop[name]) :
+ f(name, prop[name]) :
prop[name];
}

0 comments on commit 42e9d0d

Please sign in to comment.