Created
October 15, 2013 11:02
-
-
Save Sija/6989928 to your computer and use it in GitHub Desktop.
This file contains 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
moduleKeywords = ['extended', 'included'] | |
class Module | |
@extend: (obj) -> | |
for key, value of obj when key not in moduleKeywords | |
@[key] = value | |
obj.extended?.apply(@) | |
this | |
@include: (obj) -> | |
for key, value of obj when key not in moduleKeywords | |
# Assign properties to the prototype | |
@::[key] = value | |
obj.included?.apply(@) | |
this |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment