11var _ = require ( 'lodash' ) ;
2- var inflection = require ( 'inflection' ) ;
32var utils = require ( './utils' ) ;
43
54module . exports = function serializer ( type , data , relations , options ) {
@@ -44,8 +43,6 @@ function parseResource (type, data, relations, options) {
4443 var attributes = { } ;
4544 var relationships ;
4645
47- type = inflection . pluralize ( type ) ;
48- type = caserize ( type , options . keyForRelation ) ;
4946 resource . type = type ;
5047 relationships = parseRelations ( data , relations , options ) ;
5148
@@ -57,7 +54,6 @@ function parseResource (type, data, relations, options) {
5754 if ( property === 'id' ) {
5855 resource . id = _ ( value ) . toString ( ) ;
5956 } else {
60- property = caserize ( property , options . keyForAttribute ) ;
6157 attributes [ property ] = value ;
6258 }
6359 } ) ;
@@ -141,7 +137,6 @@ function parseRelations (data, relations, options) {
141137 var pk = data [ pkName ] ;
142138 var fk = data [ fkName ] ;
143139
144- name = caserize ( name , options . keyForRelation ) ;
145140 var fromType = utils . pluralForModel ( relation . modelFrom ) ;
146141 var toType = utils . pluralForModel ( relation . modelTo ) ;
147142
@@ -193,7 +188,7 @@ function makeRelation (type, id, options) {
193188 }
194189
195190 return {
196- type : caserize ( type , options . keyForRelation ) ,
191+ type : type ,
197192 id : id
198193 } ;
199194}
@@ -238,23 +233,3 @@ function makeLinks (links, item) {
238233
239234 return retLinks ;
240235}
241-
242- /**
243- * Handles converting string cases.
244- * @param {String } value
245- * @param {String } type
246- * @return {String }
247- */
248- function caserize ( value , type ) {
249- type = type || 'dash-case' ;
250-
251- var mapping = {
252- 'dash-case' : _ . kebabCase ,
253- 'underscore_case' : inflection . underscore ,
254- 'camelCase' : _ . camelCase ,
255- 'Classify' : inflection . classify
256- } ;
257-
258- var func = mapping [ type ] ;
259- return func ( value ) ;
260- }
0 commit comments