Comparing version 0.0.3 to 0.0.4
{ | ||
"name": "minimo", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"main": "dist/minimo.min.js", | ||
@@ -5,0 +5,0 @@ "ignore": [ |
@@ -67,3 +67,3 @@ (function(root, undefined) { | ||
var generateModelObject = function(members) { | ||
return function(contructorArguments) { | ||
var ConstructorFunction = function(contructorArguments) { | ||
var _this = this, | ||
@@ -143,6 +143,12 @@ observers = [], | ||
}; | ||
ConstructorFunction.factory = function(contructorArguments) { | ||
return new ConstructorFunction(contructorArguments); | ||
}; | ||
return ConstructorFunction; | ||
}; | ||
// Version. | ||
generateModelObject.VERSION = '0.0.3'; | ||
generateModelObject.VERSION = '0.0.4'; | ||
@@ -149,0 +155,0 @@ |
/*! minimo 06-08-2014 */ | ||
!function(a){"use strict";var b=function(a,b){var c=0;if(a){if(a.indexOf)c=a.indexOf(b);else for(c=0;c<a.length&&a[c]!==b;++c);if(c>=0&&c<a.length)return a.splice(c,1),!0}return!1},c=function(a,b,c){var d=a.slice(),e=d.length,f=null,g=0;for(g=0;e>g;++g)(f=d[g])(b,c)},d=function(a,d){var e=[],f=a,g=function(){var a=f;return arguments.length>0?(f!==arguments[0]&&(f=arguments[0],c(e,f,a)),d):f};return g.observe=function(a){e.push(a)},g.unobserve=function(a){b(e,a)},g},e=function(a){return function(e){var f=this,g=[],h=function(){c(g,f)},i=null,j=null;for(i in a)a.hasOwnProperty(i)&&(j=e&&e.hasOwnProperty(i)?e[i]:a[i],this[i]=d(j,f));this.observe=function(b){var c=null;if(0===g.length&&b)for(c in a)a.hasOwnProperty(c)&&f[c].observe(h);g.push(b)},this.unobserve=function(c){var d=null;if(b(g,c),0===g.length)for(d in a)a.hasOwnProperty(d)&&f[d].unobserve(h)},this.fromPojo=function(b){var c=null,d=null;if(b)for(c in a)a.hasOwnProperty(c)&&(d=b.hasOwnProperty(c)?b[c]:a[c],f[c](d));return f},this.toPojo=function(){var b=null,c={};for(b in a)a.hasOwnProperty(b)&&(c[b]=f[b]());return c}}};e.VERSION="0.0.3",module&&module.exports?module.exports=e:a.minimo=e}(this); | ||
!function(a){"use strict";var b=function(a,b){var c=0;if(a){if(a.indexOf)c=a.indexOf(b);else for(c=0;c<a.length&&a[c]!==b;++c);if(c>=0&&c<a.length)return a.splice(c,1),!0}return!1},c=function(a,b,c){var d=a.slice(),e=d.length,f=null,g=0;for(g=0;e>g;++g)(f=d[g])(b,c)},d=function(a,d){var e=[],f=a,g=function(){var a=f;return arguments.length>0?(f!==arguments[0]&&(f=arguments[0],c(e,f,a)),d):f};return g.observe=function(a){e.push(a)},g.unobserve=function(a){b(e,a)},g},e=function(a){var e=function(e){var f=this,g=[],h=function(){c(g,f)},i=null,j=null;for(i in a)a.hasOwnProperty(i)&&(j=e&&e.hasOwnProperty(i)?e[i]:a[i],this[i]=d(j,f));this.observe=function(b){var c=null;if(0===g.length&&b)for(c in a)a.hasOwnProperty(c)&&f[c].observe(h);g.push(b)},this.unobserve=function(c){var d=null;if(b(g,c),0===g.length)for(d in a)a.hasOwnProperty(d)&&f[d].unobserve(h)},this.fromPojo=function(b){var c=null,d=null;if(b)for(c in a)a.hasOwnProperty(c)&&(d=b.hasOwnProperty(c)?b[c]:a[c],f[c](d));return f},this.toPojo=function(){var b=null,c={};for(b in a)a.hasOwnProperty(b)&&(c[b]=f[b]());return c}};return e.factory=function(a){return new e(a)},e};e.VERSION="0.0.4",module&&module.exports?module.exports=e:a.minimo=e}(this); |
{ | ||
"name": "minimo", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"main": "dist/minimo.min.js", | ||
@@ -5,0 +5,0 @@ "description": "A Minimal Data Model Library", |
@@ -62,3 +62,3 @@ /* minimo main */ | ||
var generateModelObject = function(members) { | ||
return function(contructorArguments) { | ||
var ConstructorFunction = function(contructorArguments) { | ||
var _this = this, | ||
@@ -138,6 +138,12 @@ observers = [], | ||
}; | ||
ConstructorFunction.factory = function(contructorArguments) { | ||
return new ConstructorFunction(contructorArguments); | ||
}; | ||
return ConstructorFunction; | ||
}; | ||
// Version. | ||
generateModelObject.VERSION = '0.0.3'; | ||
generateModelObject.VERSION = '0.0.4'; | ||
@@ -144,0 +150,0 @@ |
@@ -52,2 +52,19 @@ test("the library function exists", function() { | ||
test("a set of model objects can be created from an array of pojos", function( ) { | ||
var pojos = [ | ||
{objectProperty: "Value 1"}, | ||
{objectProperty: "Value 2"}, | ||
{objectProperty: "Value 3"}, | ||
{objectProperty: "Value 4"} | ||
], | ||
Person = minimo({objectProperty:""}), | ||
persons = pojos.map(Person.factory), | ||
index = 0; | ||
for (index = 0; index < pojos.length; ++index) { | ||
equal(persons[index].objectProperty(), pojos[index].objectProperty, "objectProperty has \"" + pojos[index].objectProperty + "\""); | ||
} | ||
}); | ||
var propertyTestGenerator = function(defaultValue, newValue) { | ||
@@ -54,0 +71,0 @@ return function() { |
95688
2890