lmartins
3/7/2014 - 8:01 PM

Module Pattern in CoffeeScript

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 {} )