{"_id":"Backbone.Aggregator","_rev":"7-a58fc8933a5be8c6923dee237df77acd","name":"Backbone.Aggregator","description":"Provides a collection-like constructor that allows you create aggregators from different collections","dist-tags":{"latest":"0.0.3"},"versions":{"0.0.2":{"name":"Backbone.Aggregator","description":"Provides a collection-like constructor that allows you create aggregators from different collections","version":"0.0.2","author":{"name":"Pau ramon","email":"masylum@gmail.com"},"repository":{"type":"git","url":"git://github.com/masylum/Backbone.Aggregator.git"},"devDependencies":{"backbone":"*","underscore":"*","mocha":"*"},"main":"./backbone.aggregator","_npmUser":{"name":"masylum","email":"masylum@gmail.com"},"_id":"Backbone.Aggregator@0.0.2","dependencies":{},"engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.0.105","_nodeVersion":"v0.4.10","_defaultsLoaded":true,"dist":{"shasum":"10eec01af42f79bc28e26740660d057160d11d11","tarball":"https://registry.npmjs.org/Backbone.Aggregator/-/Backbone.Aggregator-0.0.2.tgz","integrity":"sha512-jacwbIhDEd0hWTXhAK5XHY8zo5TLk2U3blCu/QNqt8A/baizb25Y2jrM9iHmgY46leBVQQUf4WckAaVoRp5C4g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCe4GuIq3xWMHsQp3un8nY8PmqurrKiLtlbbNNR7sk0VQIgIsKbQaGrVRgjiD5iBTDQg7yJkW2KWN21gI37TzkexM8="}]},"maintainers":[{"name":"masylum","email":"masylum@gmail.com"}]},"0.0.3":{"name":"Backbone.Aggregator","description":"Provides a collection-like constructor that allows you create aggregators from different collections","version":"0.0.3","author":{"name":"Pau ramon","email":"masylum@gmail.com"},"repository":{"type":"git","url":"git://github.com/masylum/Backbone.Aggregator.git"},"devDependencies":{"backbone":"*","underscore":"*","mocha":"*"},"main":"./backbone.aggregator","_npmUser":{"name":"masylum","email":"masylum@gmail.com"},"_id":"Backbone.Aggregator@0.0.3","dependencies":{},"engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.0.105","_nodeVersion":"v0.4.10","_defaultsLoaded":true,"dist":{"shasum":"af82b2ec76db26c934ab08c9384221213acd5229","tarball":"https://registry.npmjs.org/Backbone.Aggregator/-/Backbone.Aggregator-0.0.3.tgz","integrity":"sha512-XBGCGrPDVkD+eN9wsDEch8u7i5v1wNjYwOoRVa7alY86yWY6dMcUMsXXPZC5Zbu2bFK+6qDlqRS7VziRlGpxOA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIB958u6DmWHObX1Z307fUt4ClEi+tMyx0p45/q/of7v0AiEA3TUz+5JaNU6gLMobH6yMZO+6BXLXRR6q172Yq21PnKI="}]},"maintainers":[{"name":"masylum","email":"masylum@gmail.com"}]}},"readme":"# Backbone.aggregator\n\nA collection that contains pointers to elements to other collections models.\n\n## Use case?\n\nHaving a polymorphic collection that just points to existant elements in your state.\n\nFor instance having a *Recent activities* that mixes *Tasks* and *Activities*,\nyou want to be sure that adding, deleting or changing a Task or Activity will\nupdate Recent Activities.\n\n## How does it work?\n\nThe API is almost the same as `Backbone.Collection`.\n\n  * You must specify which `collection` the model belongs.\n  * Each model must have a `type` attribute.\n  * The aggregator collection must implement the `collections` method. This will return a mapping of `type` and `collection`.\n  * If you want to `get` a model from the aggregator collection you must specify the type too.\n\n``` javascript\nModels.Task = Backbone.Model.extend({initialize: function () {\n  this.collection = tasks;\n}});\n\nModels.Activity = Backbone.Model.extend({initialize: function () {\n  this.collection = activities;\n}});\n\nCollections.Tasks = Backbone.Collection.extend({model: Models.Task});\nCollections.Activities = Backbone.Collection.extend({model: Models.Activity});\n\nCollections.Threads = Backbone.Aggregator.extend({\n  model: function (attr, opt) {\n    return new Models[attr.type](attr, opt);\n  }\n, collections: function () {\n    return {Task: tasks, Activity: activities};\n  }\n});\n\ntasks = new Collections.Tasks();\nactivities = new Collections.Activities();\nthreads = new Collections.Threads();\n```\n\n## Tests\n\nYou must have node installed in order to run the tests.\n\n```\nnpm install\nmake\n```\n\n## License\n\n(The MIT License)\n\nCopyright (c) 2010-2011 Pau Ramon <masylum@gmail.com>\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","maintainers":[{"name":"masylum","email":"masylum@gmail.com"}],"time":{"modified":"2022-06-13T02:13:06.377Z","created":"2011-11-25T11:50:13.092Z","0.0.2":"2011-11-25T11:50:15.102Z","0.0.3":"2011-11-25T12:10:00.138Z"},"author":{"name":"Pau ramon","email":"masylum@gmail.com"},"repository":{"type":"git","url":"git://github.com/masylum/Backbone.Aggregator.git"}}