jsonapi-renderer
Advanced tools
Comparing version 1.0.7 to 1.0.9
{ | ||
"name": "jsonapi-renderer", | ||
"version": "1.0.7", | ||
"version": "1.0.9", | ||
"description": "Helper for generating jsonapi compliant output from models", | ||
@@ -30,2 +30,3 @@ "repository": { | ||
"grunt-mocha-istanbul": "^2.4.0", | ||
"grunt-release": "^0.13.0", | ||
"istanbul": "^0.3.17", | ||
@@ -32,0 +33,0 @@ "load-grunt-config": "^0.17.1", |
@@ -83,6 +83,6 @@ 'use strict'; | ||
//Create a resolver function | ||
descriptor.resolve = function(model) { | ||
descriptor.resolve = function(model, options) { | ||
var value; | ||
if (descriptor.get) { | ||
value = descriptor.get.call(model); | ||
value = descriptor.get.call(model, options); | ||
} else if (descriptor.property) { | ||
@@ -89,0 +89,0 @@ value = model[descriptor.property]; |
@@ -54,3 +54,3 @@ 'use strict'; | ||
if (descriptor.id) { | ||
id = descriptor.id.resolve(model).value(); | ||
id = descriptor.id.resolve(model, options.resolution).value(); | ||
if (_.isNull(id)) { | ||
@@ -78,3 +78,3 @@ return Promise.resolve(null); | ||
return descriptor.resolve(model).then(function(relatedModel) { | ||
return descriptor.resolve(model, options.resolution).then(function(relatedModel) { | ||
if (_.isArray(relatedModel)) { | ||
@@ -100,3 +100,3 @@ return Promise.mapSeries(relatedModel, function(subRelatedModel) { | ||
var type = definition.type; | ||
var id = definition.id.resolve(model).value(); | ||
var id = definition.id.resolve(model, options.resolution).value(); | ||
var identifier = this.renderResourceIdentifier(type, id); | ||
@@ -176,3 +176,3 @@ | ||
var definition = this.registry.getByModel(model); | ||
var id = definition.id.resolve(model).value(); | ||
var id = definition.id.resolve(model, options.resolution).value(); | ||
@@ -192,3 +192,3 @@ var data = this.renderResourceBasic(definition.type, id, definition); | ||
return Promise.mapSeries(_.keys(attributesToRender), function(name) { | ||
return attributesToRender[name].resolve(model).then(function(value) { | ||
return attributesToRender[name].resolve(model, options.resolution).then(function(value) { | ||
data.attributes[name] = value; | ||
@@ -195,0 +195,0 @@ }); |
17935
12