Sha256: 3f36dd8ffaa6b7092a6bcc73d16157b1367b82a51aa87719b942a79b0f9fd682
Contents?: true
Size: 1.2 KB
Versions: 14
Compression:
Stored size: 1.2 KB
Contents
//= require ./CollectionQueryParameters class BaseCollection extends Backbone.Collection { constructor(model, options) { super(model, options) this.queryParameters = new CollectionQueryParameters(this) } // Returns the collection class for a resource name, using our model // convention, i.e. // 'foos' -> App.Models.Foo.Collection static collectionClassForResource(resourceName) { return BaseModel.modelClassForResource(resourceName).Collection } // Return a collection class with intelligent defaults based on the resource // name, i.e. model class and urls set from the resource name // The class can be further extended through the typical mechanisms static forResource(resourceName) { return class extends BaseCollection { get model() { return BaseModel.modelClassForResource(resourceName) } //jsonapi-resources dasherizes multi-word resources by default url() { return `/${_.str.dasherize(resourceName)}.json` } } } handleLinks(topLevelLinks) { this.queryParameters.handleLinks(topLevelLinks) } fetch(options = {}) { if(!options.data) { options.data = this.queryParameters.fetchData } super.fetch(options) } }
Version data entries
14 entries across 14 versions & 1 rubygems