summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/models/auto_collection.js.coffee
blob: 335e9ad2f1fb381e8d62babea7492315cd480e5a (plain)
1
2
3
4
5
6
7
8
9
10
class csx.AutoCollection
  @install: (modelName, pluralName, json) ->
    model = csx.Models[modelName]
    if _.isUndefined(model)
      csx.Collections[modelName] = new Backbone.Collection(json)
    else
      collection = Backbone.Collection.extend
        model: model
        url: "/api/v1/#{pluralName}"
      csx.Collections[modelName] = new collection(json)