Last active
August 29, 2015 14:07
-
-
Save syntruth/4d32a87e8d9fc6a33be5 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
class Module | |
@moduleKeywords = ['instance', 'extended', 'included'] | |
@extend: (obj, mixin) -> | |
for key, value of mixin when key not in @moduleKeywords | |
obj[key] = value | |
if typeof mixin.instance is 'object' | |
@include obj, mixin.instance | |
return obj | |
@include: (obj, mixin) -> | |
for key, value of mixin when key not in @moduleKeywords | |
# Assign properties to the prototype | |
obj::[key] = value | |
return obj | |
this.Module = Module |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment