Skip to content

Instantly share code, notes, and snippets.

@south37
Created February 1, 2014 02:07
Show Gist options
  • Save south37/8746972 to your computer and use it in GitHub Desktop.
Save south37/8746972 to your computer and use it in GitHub Desktop.
Class = {}
Class.def = do ->
curry = (fn) ->
slice = Array.prototype.slice
storedArgs = slice.call(arguments, 1)
return ->
newArgs = slice.call(arguments)
args = storedArgs.concat(newArgs)
fn.apply(null, args)
return (classSpec) ->
for name, methods of classSpec
Class[name] = ->
obj = {}
self = {}
init = curry(methods.init, self)
init.apply(null, arguments)
for methodName, method of methods
if methodName isnt 'init'
obj[methodName] = curry(method, self)
return obj
Class.def 'Quo':
init: (self, status) ->
self.status = status
status: (self) ->
self.status
myQuo = Class.Quo 'ok'
console.log do myQuo.status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment