Skip to content

Instantly share code, notes, and snippets.

@Sija
Created October 15, 2013 11:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sija/6989928 to your computer and use it in GitHub Desktop.
Save Sija/6989928 to your computer and use it in GitHub Desktop.
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