Skip to content

Instantly share code, notes, and snippets.

@h2rd
Created April 8, 2012 10:41
Show Gist options
  • Save h2rd/2336533 to your computer and use it in GitHub Desktop.
Save h2rd/2336533 to your computer and use it in GitHub Desktop.
Mixin
moduleKeywords = ['included', 'extended']
class Module
@extend: (object) ->
for key, value of object when key not in moduleKeywords
@[key] = value
object.included?.apply(@)
this
@include: (object) ->
for key, value of object when key not in moduleKeywords
@::[key] = value
object.included?.apply(@)
this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment