Skip to content

Instantly share code, notes, and snippets.

@BlairLeduc
Created September 8, 2012 13:03
Show Gist options
  • Save BlairLeduc/3674734 to your computer and use it in GitHub Desktop.
Save BlairLeduc/3674734 to your computer and use it in GitHub Desktop.
Revealing Module Pattern in CoffeeScript
@zed = @zed ? {}
@zed.info = do ->
#private
name = ""
getName = -> name
setName = (value) -> name = value
age = 0
getAge = -> age
setAge = (value) -> age = value
eat = (food) ->
if food?
alert "Yummy #{food}!"
else
alert "I'm still hungry!"
# public
getName: getName
setName: setName
getAge: getAge
setAge: setAge
eat: eat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment