Skip to content

Instantly share code, notes, and snippets.

@craigmaslowski
Last active December 10, 2015 14:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save craigmaslowski/4449150 to your computer and use it in GitHub Desktop.
Save craigmaslowski/4449150 to your computer and use it in GitHub Desktop.
Backbone.puree = function (config) {
if (config.all) {
config.view = config.view || [];
config.collection = config.collection || [];
config.model = config.model || [];
config.view = config.view.concat(config.all);
config.collection = config.collection.concat(config.all);
config.model = config.model.concat(config.all);
}
_.each(config.view, function (mixin) {
Backbone.mixin(Backbone.View, mixin);
});
_.each(config.collection, function (mixin) {
Backbone.mixin(Backbone.Collection, mixin);
});
_.each(config.model, function (mixin) {
Backbone.mixin(Backbone.Model, mixin);
if (Backbone.DeepModel) {
Backbone.mixin(Backbone.DeepModel, mixin);
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment