Skip to content

Instantly share code, notes, and snippets.

@lmartins
Created March 7, 2014 20:01
Show Gist options
  • Save lmartins/9418842 to your computer and use it in GitHub Desktop.
Save lmartins/9418842 to your computer and use it in GitHub Desktop.
Module Pattern in CoffeeScript
Module = (->
_privateMethod = ->
console.log "Some text from the private method, called from the public method"
publicMethod = ->
console.log "something from the public method"
_privateMethod()
# métodos públicos que são expostos através do módulo
return publicAPI =
publicMethod: publicMethod
)()
# ModuleTwo extends the functionality of Module
ModuleTwo = ( (Module) ->
Module.extension = ->
console.log "Text from the extension Module"
return Module
)( Module or {} )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment