Skip to content

Commit

Permalink
Merge pull request #49 from kmudrick/Fix_For_LoDash3
Browse files Browse the repository at this point in the history
Update to work with lodash v3.  Fixes #48
  • Loading branch information
mrjoelkemp committed Jan 30, 2015
2 parents e892aa5 + ab23526 commit 786d075
Show file tree
Hide file tree
Showing 3 changed files with 10,804 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Cocktail.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@

var collisions = {};

_(mixins).each(function(mixin) {
_.each(mixins, function(mixin) {
if (_.isString(mixin)) {
mixin = Cocktail.mixins[mixin];
}
_(mixin).each(function(value, key) {
_.each(mixin, function(value, key) {
if (_.isFunction(value)) {
// If the mixer already has that exact function reference
// Note: this would occur on an accidental mixin of the same base
Expand All @@ -48,13 +48,13 @@
});
});

_(collisions).each(function(propertyValues, propertyName) {
_.each(collisions, function(propertyValues, propertyName) {
obj[propertyName] = function() {
var that = this,
args = arguments,
returnValue;

_(propertyValues).each(function(value) {
_.each(propertyValues, function(value) {
var returnedValue = _.isFunction(value) ? value.apply(that, args) : value;
returnValue = (typeof returnedValue === 'undefined' ? returnValue : returnedValue);
});
Expand Down Expand Up @@ -82,7 +82,7 @@
return klass;
};

_([Backbone.Model, Backbone.Collection, Backbone.Router, Backbone.View]).each(function(klass) {
_.each([Backbone.Model, Backbone.Collection, Backbone.Router, Backbone.View], function(klass) {
klass.mixin = function mixin() {
Cocktail.mixin(this, _.toArray(arguments));
};
Expand All @@ -92,7 +92,7 @@
};

Cocktail.unpatch = function unpatch(Backbone) {
_([Backbone.Model, Backbone.Collection, Backbone.Router, Backbone.View]).each(function(klass) {
_.each([Backbone.Model, Backbone.Collection, Backbone.Router, Backbone.View], function(klass) {
klass.mixin = undefined;
klass.extend = originalExtend;
});
Expand Down
13 changes: 13 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,19 @@ module.exports = function(grunt) {
'externals/backbone.js'
]
}
},
components_lodash: {
src: ['Cocktail.js'],
options: {
specs: 'spec/spec/*Spec.js',
keepRunner : true,
helpers: 'spec/SpecHelper.js',
vendor: [
'externals/jquery-1.7.2.js',
'externals/lodash.js',
'externals/backbone.js'
]
}
}
}
});
Expand Down
Loading

0 comments on commit 786d075

Please sign in to comment.