Skip to content

Instantly share code, notes, and snippets.

@maciejhirsz
Created August 27, 2014 13:58
Show Gist options
  • Save maciejhirsz/38695f772a4117aa0d9e to your computer and use it in GitHub Desktop.
Save maciejhirsz/38695f772a4117aa0d9e to your computer and use it in GitHub Desktop.
Magic config inheritance
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