Skip to content

Instantly share code, notes, and snippets.

@nthx
Created May 16, 2012 23:24
Show Gist options
  • Save nthx/2714870 to your computer and use it in GitHub Desktop.
Save nthx/2714870 to your computer and use it in GitHub Desktop.
hashmal modified Mixin
Swappable Mixins in CoffeeScript
# ================================
# Many thanks to Hashmal, who wrote this to start.
# https://gist.github.com/803816/aceed8fc57188c3a19ce2eccdb25acb64f2be94e
class Mixin
augment: (t) ->
(t[n] = m unless n == 'augment' or !this[n].prototype?) for n, m of this
t.setup()
eject: (mixin) ->
(delete this[n] if m in (p for o, p of mixin::)) for n, m of this
setup: ->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment