Skip to content
Browse files

build v0.0.1

  • Loading branch information...
1 parent 42d781a commit ab064deac9ada0a7341625d9bfd88571cfe4b853 @derickbailey committed Sep 23, 2012
View
16 lib/amd/backbone.compute.js
@@ -1,4 +1,4 @@
-// Backbone.Compute, v0.0.0
+// Backbone.Compute, v0.0.1
// Copyright (c)2012 Derick Bailey, Muted Solutions, LLC.
// Distributed under MIT license
// http://github.com/derickbailey/backbone.compute
@@ -27,9 +27,13 @@
// model's `initialize` function.
function initializeModel(obj){
for(var field in obj){
- if (obj[field] && obj[field].computedField){
+ var computeAttr = obj[field];
+
+ if (computeAttr && computeAttr.fields && computeAttr.compute){
+ obj[field] = computeField(field, computeAttr.fields, computeAttr.compute);
obj[field].call(obj);
}
+
}
}
@@ -89,12 +93,8 @@
// The raw API for computed fields. Determines whether
// you are attempting to initialize the model or define
// a computed field, and call the correct behavior.
- var Compute = function(){
- if (arguments.length === 1){
- return initializeModel(arguments[0]);
- } else {
- return computeField.apply(null, arguments);
- }
+ var Compute = function(model){
+ return initializeModel(model);
};
return Compute;
View
4 lib/amd/backbone.compute.min.js
@@ -1,5 +1,5 @@
-// Backbone.Compute, v0.0.0
+// Backbone.Compute, v0.0.1
// Copyright (c)2012 Derick Bailey, Muted Solutions, LLC.
// Distributed under MIT license
// http://github.com/derickbailey/backbone.compute
-(function(e,t){if(typeof exports=="object"){var n=require("underscore"),r=require("backbone");module.exports=t(n,r)}else typeof define=="function"&&define.amd&&define(["underscore","backbone"],t)})(this,function(e,t){return t.Compute=function(e,t){function n(e){for(var t in e)e[t]&&e[t].computedField&&e[t].call(e)}function r(e,n,r){n=t.flatten([n]);var i=n.length,s=function(){var t={};for(var s=0;s<i;s++){var o=n[s];t[o]=this.get(o)}var u=r.call(this,t);return this.set(e,u),u},o=function(){var e=t.bind(s,this);for(var r=0;r<i;r++){var o=n[r];this.on("change:"+o,e)}return e()};return o.computedField=!0,o}var i=function(){return arguments.length===1?n(arguments[0]):r.apply(null,arguments)};return i}(t,e),t.Compute});
+(function(e,t){if(typeof exports=="object"){var n=require("underscore"),r=require("backbone");module.exports=t(n,r)}else typeof define=="function"&&define.amd&&define(["underscore","backbone"],t)})(this,function(e,t){return t.Compute=function(e,t){function n(e){for(var t in e){var n=e[t];n&&n.fields&&n.compute&&(e[t]=r(t,n.fields,n.compute),e[t].call(e))}}function r(e,n,r){n=t.flatten([n]);var i=n.length,s=function(){var t={};for(var s=0;s<i;s++){var o=n[s];t[o]=this.get(o)}var u=r.call(this,t);return this.set(e,u),u},o=function(){var e=t.bind(s,this);for(var r=0;r<i;r++){var o=n[r];this.on("change:"+o,e)}return e()};return o.computedField=!0,o}var i=function(e){return n(e)};return i}(t,e),t.Compute});
View
16 lib/backbone.compute.js
@@ -1,4 +1,4 @@
-// Backbone.Compute, v0.0.0
+// Backbone.Compute, v0.0.1
// Copyright (c)2012 Derick Bailey, Muted Solutions, LLC.
// Distributed under MIT license
// http://github.com/derickbailey/backbone.compute
@@ -12,9 +12,13 @@ Backbone.Compute = (function(Backbone, _){
// model's `initialize` function.
function initializeModel(obj){
for(var field in obj){
- if (obj[field] && obj[field].computedField){
+ var computeAttr = obj[field];
+
+ if (computeAttr && computeAttr.fields && computeAttr.compute){
+ obj[field] = computeField(field, computeAttr.fields, computeAttr.compute);
obj[field].call(obj);
}
+
}
}
@@ -74,12 +78,8 @@ Backbone.Compute = (function(Backbone, _){
// The raw API for computed fields. Determines whether
// you are attempting to initialize the model or define
// a computed field, and call the correct behavior.
- var Compute = function(){
- if (arguments.length === 1){
- return initializeModel(arguments[0]);
- } else {
- return computeField.apply(null, arguments);
- }
+ var Compute = function(model){
+ return initializeModel(model);
};
return Compute;
View
4 lib/backbone.compute.min.js
@@ -1,5 +1,5 @@
-// Backbone.Compute, v0.0.0
+// Backbone.Compute, v0.0.1
// Copyright (c)2012 Derick Bailey, Muted Solutions, LLC.
// Distributed under MIT license
// http://github.com/derickbailey/backbone.compute
-Backbone.Compute=function(e,t){function n(e){for(var t in e)e[t]&&e[t].computedField&&e[t].call(e)}function r(e,n,r){n=t.flatten([n]);var i=n.length,s=function(){var t={};for(var s=0;s<i;s++){var o=n[s];t[o]=this.get(o)}var u=r.call(this,t);return this.set(e,u),u},o=function(){var e=t.bind(s,this);for(var r=0;r<i;r++){var o=n[r];this.on("change:"+o,e)}return e()};return o.computedField=!0,o}var i=function(){return arguments.length===1?n(arguments[0]):r.apply(null,arguments)};return i}(Backbone,_);
+Backbone.Compute=function(e,t){function n(e){for(var t in e){var n=e[t];n&&n.fields&&n.compute&&(e[t]=r(t,n.fields,n.compute),e[t].call(e))}}function r(e,n,r){n=t.flatten([n]);var i=n.length,s=function(){var t={};for(var s=0;s<i;s++){var o=n[s];t[o]=this.get(o)}var u=r.call(this,t);return this.set(e,u),u},o=function(){var e=t.bind(s,this);for(var r=0;r<i;r++){var o=n[r];this.on("change:"+o,e)}return e()};return o.computedField=!0,o}var i=function(e){return n(e)};return i}(Backbone,_);
View
8 src/backbone.compute.js
@@ -9,14 +9,12 @@ Backbone.Compute = (function(Backbone, _){
function initializeModel(obj){
for(var field in obj){
var computeAttr = obj[field];
- if (computeAttr
- && computeAttr.fields
- && computeAttr.compute
- ){
-
+
+ if (computeAttr && computeAttr.fields && computeAttr.compute){
obj[field] = computeField(field, computeAttr.fields, computeAttr.compute);
obj[field].call(obj);
}
+
}
}

0 comments on commit ab064de

Please sign in to comment.
Something went wrong with that request. Please try again.