diamond.js
Advanced tools
Comparing version 0.2.24 to 0.2.25
@@ -5,3 +5,4 @@ // Generated by CoffeeScript 1.8.0 | ||
__hasProp = {}.hasOwnProperty, | ||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; | ||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, | ||
__slice = [].slice; | ||
@@ -23,2 +24,26 @@ Property = require('./model/property'); | ||
Model.hasOne = function(name, type, options) { | ||
if (options == null) { | ||
options = {}; | ||
} | ||
this.properties = this.properties || new Object; | ||
options.key || (options.key = "_id"); | ||
this.properties[name] = 0; | ||
return this.properties[name] = new Property(this, name, (function() { | ||
var args; | ||
args = 1 <= arguments.length ? __slice.call(arguments, 0) : []; | ||
return (function(func, args, ctor) { | ||
ctor.prototype = func.prototype; | ||
var child = new ctor, result = func.apply(child, args); | ||
return Object(result) === result ? result : child; | ||
})(type, args, function(){}); | ||
}), { | ||
save: function(m) { | ||
return (typeof m.get === "function" ? m.get(options.key) : void 0) || m; | ||
} | ||
}); | ||
}; | ||
Model.hasMany = function() {}; | ||
Model.validation = function(name, options) { | ||
@@ -25,0 +50,0 @@ this.validations = this.validations || new Object; |
@@ -42,3 +42,3 @@ // Generated by CoffeeScript 1.8.0 | ||
} else if (value.constructor !== this.type) { | ||
value = this.type.prototype && !isPrimitive(this.type) ? new this.type(value) : this.type(value); | ||
value = this.type(value); | ||
} | ||
@@ -45,0 +45,0 @@ return value; |
{ | ||
"name": "diamond.js", | ||
"description": "Generic MVC web framework", | ||
"version": "0.2.24", | ||
"version": "0.2.25", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Arthur Xavier", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
36749
512