Skip to content

Instantly share code, notes, and snippets.

@codelinq
codelinq / setter_pattern.coffee
Created August 9, 2012 14:57 — forked from alexaivars/setter_pattern.coffee
Getter Setter patter for Coffeescript
Function::define = (prop, desc) ->
Object.defineProperty this.prototype, prop, desc
class GetterSetterTest
constructor: (@_obj = {}) ->
# 'obj' is defined via the prototype, the definition proxied through
# to 'Object.defineProperty' via a function called 'define' providing
# some nice syntactic sugar. Remember, the value of '@' is
# GetterSetterTest itself when used in the body of it's class definition.