Skip to content

Instantly share code, notes, and snippets.

@vendethiel
Last active February 16, 2016 19:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vendethiel/5087bbd98814e2eaff9b to your computer and use it in GitHub Desktop.
Save vendethiel/5087bbd98814e2eaff9b to your computer and use it in GitHub Desktop.
# models
class Models
constructor: (@db) ->
channel: (name) -> new Channel(@db, name)
# channel
class Channel
constructor: (@db) ->
foo: -> @db.query '...'
# osu plugin
class Plugins.Osu
constructor: (@models) ->
onReceiveMessage: (name) ->
channel = @models.channel name
channel.foo()
# init code
redis.connect params, (db) ->
models = new Models(db)
plugins = for key in 'a b c d'.split(' ') # just as an example
plugin = require "./#{key}"
new plugin(models)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment