Created
August 27, 2014 13:58
-
-
Save maciejhirsz/38695f772a4117aa0d9e to your computer and use it in GitHub Desktop.
Magic config inheritance
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
class Base | |
constructor: -> | |
@config() | |
config: -> | |
magic = (options) => | |
@config = {} if typeof @config is 'function' | |
@config[option] = value for option, value of options | |
return magic | |
class Thing extends Base | |
config: -> | |
super() | |
foo: 100 | |
bar: 200 | |
bool: true | |
class ExtendedThing extends Thing | |
config: -> | |
super() | |
success: 'success' | |
fail: 'fail' | |
et = new ExtendedThing | |
console.log et.config |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment