Permalink
Browse files

Use getValue instead of _.result, remove extra args from getValue

  • Loading branch information...
1 parent e4a3868 commit 9624f738f94608818a3e9c215148ce0bfa6befac Ryan Eastridge committed Jan 3, 2013
Showing with 5 additions and 2 deletions.
  1. +1 −1 src/collection.js
  2. +4 −1 src/util.js
View
@@ -20,7 +20,7 @@ Thorax.Collection = Backbone.Collection.extend({
return this._fetched || this.length > 0 || (!this.length && !getValue(this, 'url'));
},
shouldFetch: function(options) {
- return options.fetch && !!_.result(this, 'url') && !this.isPopulated();
+ return options.fetch && !!getValue(this, 'url') && !this.isPopulated();
},
fetch: function(options) {
options = options || {};
View
@@ -27,12 +27,15 @@ function registryGet(object, type, name, ignoreErrors) {
}
}
+// getValue is used instead of _.result because we
+// need an extra scope parameter, and will minify
+// better than _.result
function getValue(object, prop, scope) {
if (!(object && object[prop])) {
return null;
}
return _.isFunction(object[prop])
- ? object[prop].apply(scope || object, Array.prototype.slice.call(arguments, 2))
+ ? object[prop].call(scope || object)
: object[prop];
}

0 comments on commit 9624f73

Please sign in to comment.