Skip to content

Instantly share code, notes, and snippets.

@oelmekki
Created April 6, 2011 19:10
Show Gist options
  • Save oelmekki/906301 to your computer and use it in GitHub Desktop.
Save oelmekki/906301 to your computer and use it in GitHub Desktop.
Class.Mutators.ClassMethods = function( methods ){
this.__classMethods = Object.append( this.__classMethods || {}, methods );
this.extend( methods );
};
Class.Mutators.Extends = function( parent ){
this.parent = parent;
parent.$prototyping = true;
this.prototype = new parent;
delete parent.$prototyping;
this.implement( 'parent', function(){
var name, previous;
name = this.caller._name;
previous = this.caller._owner.parent.prototype[ name ];
if ( ! previous ){
throw new Error( 'The method"' + name + '" has no parent.' );
}
return previous.apply( this, arguments );
}.protect());
this.extend( parent.__classMethods );
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment