Browse files

exposing the 'augment' function as Backbone.Augment so it can be used…

… by other libraries easier
  • Loading branch information...
1 parent fcb1aa0 commit f5f18d4a0812a19d193724b72699af4f28302ab7 @derickbailey derickbailey committed Oct 22, 2012
Showing with 15 additions and 1 deletion.
  1. +4 −0 spec/augment.spec.js
  2. +11 −1 src/backbone.augment.js
View
4 spec/augment.spec.js
@@ -4,6 +4,10 @@
describe("augment", function() {
'use strict';
+ it("should be available as Backbone.Augment", function(){
+ expect(typeof Backbone.Augment).toEqual("function");
+ });
+
it("should exist on all core backbone objects", function() {
expect(typeof Backbone.Model.augment).toEqual('function');
expect(typeof Backbone.Collection.augment).toEqual('function');
View
12 src/backbone.augment.js
@@ -9,6 +9,12 @@
}(this, function (Backbone) {
"use strict";
+ // Augment
+ // -------
+ //
+ // Augment an object with additional functionality, allowing
+ // object composition instead of just inheritance or simple
+ // extend functions
function augment(/* augments... */) {
var self = this;
for (var i = 0; i < arguments.length; i++) {
@@ -29,7 +35,11 @@
return self;
}
- Backbone.Model.augment = Backbone.Collection.augment = Backbone.View.augment = augment;
+ Backbone.Augment =
+ Backbone.Model.augment =
+ Backbone.Collection.augment =
+ Backbone.View.augment =
+ augment;
return augment;
}));

0 comments on commit f5f18d4

Please sign in to comment.