Created
May 20, 2009 01:23
-
-
Save jaredatron/114550 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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