Created
March 7, 2014 20:01
-
-
Save lmartins/9418842 to your computer and use it in GitHub Desktop.
Module Pattern in CoffeeScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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