Skip to content

Instantly share code, notes, and snippets.

@syntruth
Last active August 29, 2015 14:07
Show Gist options
  • Save syntruth/4d32a87e8d9fc6a33be5 to your computer and use it in GitHub Desktop.
Save syntruth/4d32a87e8d9fc6a33be5 to your computer and use it in GitHub Desktop.
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