Comparing version 0.0.18 to 0.0.19
@@ -279,6 +279,6 @@ var util = require('util'), | ||
if (skipNotFound) { | ||
value = this._model.serialize(name,value,this); | ||
value = this._model.get(name,value,this); | ||
} | ||
else { | ||
value = this._model.deserialize(name,value,this); | ||
value = this._model.set(name,value,this); | ||
} | ||
@@ -285,0 +285,0 @@ |
@@ -58,3 +58,3 @@ var util = require('util'), | ||
var excludeMethods = ['getConnector','getMeta','setMeta','serialize','deserialize','keys','instance','getModels','find']; | ||
var excludeMethods = ['getConnector','getMeta','setMeta','get','set','keys','instance','getModels','find']; | ||
@@ -456,9 +456,9 @@ function curryRequestDispatcher(model, fn, name, scope, request) { | ||
/** | ||
* called to serialize a field. will allow model definitions to | ||
* called to get a field. will allow model definitions to | ||
* provide a mapping function | ||
*/ | ||
Model.prototype.serialize = function serialize(name, value, instance) { | ||
Model.prototype.get = function get(name, value, instance) { | ||
var mapper = this.mappings[name] || this.fields[name]; | ||
if (mapper) { | ||
var fn = mapper.serialize; | ||
var fn = mapper.get; | ||
if (fn) { | ||
@@ -472,9 +472,9 @@ return fn(value, name, instance); | ||
/** | ||
* called to deserialize a field. will allow model definitions to | ||
* called to set a field. will allow model definitions to | ||
* provide a mapping function | ||
*/ | ||
Model.prototype.deserialize = function serialize(name, value, instance) { | ||
Model.prototype.set = function set(name, value, instance) { | ||
var mapper = this.mappings[name] || this.fields[name]; | ||
if (mapper) { | ||
var fn = mapper.deserialize; | ||
var fn = mapper.set; | ||
if (fn) { | ||
@@ -481,0 +481,0 @@ return fn(value, name, instance); |
{ | ||
"name": "api-orm", | ||
"version": "0.0.18", | ||
"version": "0.0.19", | ||
"description": "API Builder ORM", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1058,3 +1058,3 @@ var should = require('should'), | ||
it("should pass field name to serializer", function(){ | ||
it("should pass field name to getter", function(){ | ||
var Connector = new orm.MemoryConnector(); | ||
@@ -1072,3 +1072,3 @@ | ||
name: { | ||
serialize: function(value, name) { | ||
get: function(value, name) { | ||
_name = name; | ||
@@ -1086,3 +1086,3 @@ } | ||
it("should pass instance to serializer", function(){ | ||
it("should pass instance to getter", function(){ | ||
var Connector = new orm.MemoryConnector(); | ||
@@ -1103,3 +1103,3 @@ | ||
name: { | ||
serialize: function(value, name, instance) { | ||
get: function(value, name, instance) { | ||
_instance = instance; | ||
@@ -1130,3 +1130,3 @@ } | ||
name: { | ||
serialize: function(value) { | ||
get: function(value) { | ||
var tokens = value.split('/'); | ||
@@ -1138,3 +1138,3 @@ return { | ||
}, | ||
deserialize: function(value) { | ||
set: function(value) { | ||
return value.a + '/' + value.b; | ||
@@ -1156,3 +1156,3 @@ } | ||
it("should be able to serialize in field", function(){ | ||
it("should be able to define a getter for a field", function(){ | ||
var Connector = new orm.MemoryConnector(); | ||
@@ -1164,3 +1164,3 @@ | ||
type: String, | ||
serialize: function(value) { | ||
get: function(value) { | ||
var tokens = value.split('/'); | ||
@@ -1172,3 +1172,3 @@ return { | ||
}, | ||
deserialize: function(value) { | ||
set: function(value) { | ||
return value.a + '/' + value.b; | ||
@@ -1189,3 +1189,3 @@ } | ||
it("should be able to deserialize", function(){ | ||
it("should be able to use a setter", function(){ | ||
var Connector = new orm.MemoryConnector(); | ||
@@ -1201,3 +1201,3 @@ | ||
name: { | ||
serialize: function(value) { | ||
get: function(value) { | ||
var tokens = value.split('/'); | ||
@@ -1209,3 +1209,3 @@ return { | ||
}, | ||
deserialize: function(value) { | ||
set: function(value) { | ||
return value.a + '/' + value.b; | ||
@@ -1233,3 +1233,3 @@ } | ||
type: String, | ||
serialize: function(value) { | ||
get: function(value) { | ||
var tokens = value.split('/'); | ||
@@ -1241,3 +1241,3 @@ return { | ||
}, | ||
deserialize: function(value) { | ||
set: function(value) { | ||
return value.a + '/' + value.b; | ||
@@ -1244,0 +1244,0 @@ } |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
1
98610