Skip to content

Instantly share code, notes, and snippets.

@kriszyp
Forked from dvv/compose.coffee
Created December 22, 2010 20:13
Show Gist options
  • Save kriszyp/752032 to your computer and use it in GitHub Desktop.
Save kriszyp/752032 to your computer and use it in GitHub Desktop.
db = new Storage # external implementation
Store = (entity) ->
find: db.find.bind db, entity
get: db.get.bind db, entity
save: db.save.bind db, entity
add: db.insert.bind db, entity
remove: db.remove.bind db, entity
update: db.update.bind db, entity
patch: db.patch.bind db, entity
drop: db.drop.bind db, entity
Model = (entity, overrides) ->
Compose.create Store(entity), overrides
model = {}
model.Bar = Model 'Bar',
find: Compose.before (query) ->
[(query or '') + '&a!=null']
foos: () -> @find "foo!=null"
@dvv
Copy link

dvv commented Dec 22, 2010

class Collection --->

var Collection; Collection = function() { function Collection(name) { this.foo = 'bar'; } Collection.prototype.method = function(args) { console.log(args); Collection.__super__.method.call(this, args); return this; }; return Collection; }();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment