Created
May 16, 2012 23:24
-
-
Save nthx/2714870 to your computer and use it in GitHub Desktop.
hashmal modified Mixin
This file contains hidden or 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
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