Created
August 24, 2013 15:34
-
-
Save mikekunze/6328781 to your computer and use it in GitHub Desktop.
This is a skel for containing your Express code when it is desired to isolate app routes and websockets in classical inheritance, while potentially sharing crucial web server information such as a user session and login information.
This file contains hidden or 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
moduleKeywords = ['included', 'extended'] | |
class SuperClass | |
@include: (obj) -> | |
throw('include(obj) requires obj') unless obj | |
for key, value of obj.prototype when key not in moduleKeywords | |
@::[key] = value | |
included = obj.included | |
included.apply(this) if included | |
@ | |
class Controller | |
constructor: ()-> | |
@hasController = true | |
class Events | |
constructor: ()-> | |
@hasEvents = true | |
class Web extends SuperClass | |
@include Controller | |
@include Events | |
constructor: ()-> | |
Controller.call @ | |
Events.call @ | |
module.exports = Web |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://stackoverflow.com/questions/9064935/extending-multiple-classes-in-coffee-script