Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
## Prototype 1.6.0: copy class methods from superclass // add this before your class definitions Class.Methods.inheritClassMethods = function() { var parent = this.superclass if (!parent) return for (prop in parent) { if (prop != 'superclass' && prop != 'subclasses' && prop != 'constructor' && prop != 'prototype' && // exclude special properties !Class.Methods[prop] && // exclude Class instance methods parent[prop] !== Function.prototype[prop]) { // exclude Function instance methods this[prop] = parent[prop]; } } } ## usage example Animal.foo = function(){ ... } var Cat = Class.create(Animal, { ... }) Cat.inheritClassMethods() Cat.foo()
This paste will be private.
From the Design Piracy series on my blog: