Skip to content

Instantly share code, notes, and snippets.

@jaredatron
Created May 20, 2009 01:23
Show Gist options
  • Select an option

  • Save jaredatron/114550 to your computer and use it in GitHub Desktop.

Select an option

Save jaredatron/114550 to your computer and use it in GitHub Desktop.
var SomeMixIn = {
reusable: function(){}
}
var SomeOtherMixIn = function(class)){
with(class){
def(function moreAwesome(){
});
};
};
var Frog = Class.new(Animal, function(Frog){
with(Frog){
include(SomeMixIn);
include(SomeOtherMixIn);
def(function initialize(){
})
private();
def(function somePrivateFunc(){
return 5;
})
memoize('somePrivateFunc');
public();
def(function anotherPublicFunction(){
})
}
})
Frog.name
// => 'Frog'
// it plucks this the toString of the function passed to Class.new
Frog.superclass
// => Animal
Animal.subclasses
// => [Frog]
Frog._somePrivateFunc()
// => 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment