Permalink
Browse files

build v0.0.1

  • Loading branch information...
derickbailey committed Sep 24, 2012
1 parent 42d781a commit ab064deac9ada0a7341625d9bfd88571cfe4b853
@@ -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;

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -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;

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -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.