@@ -93,8 +93,8 @@ define("json-api-adapter",
93
93
* Suppress additional API calls if the relationship was already loaded via an `included` section
94
94
*/
95
95
findBelongsTo : function ( store , snapshot , url , relationship ) {
96
- var belongsTo = snapshot . belongsTo ( relationship . key ) ,
97
- belongsToLoaded = belongsTo && ! belongsTo . record . get ( 'currentState.isEmpty' ) ;
96
+ var belongsTo = snapshot . belongsTo ( relationship . key ) ;
97
+ var belongsToLoaded = belongsTo && ! belongsTo . record . get ( 'currentState.isEmpty' ) ;
98
98
99
99
if ( belongsToLoaded ) { return ; }
100
100
@@ -117,18 +117,18 @@ define("json-api-adapter",
117
117
* and match the root key to the route
118
118
*/
119
119
updateRecord : function ( store , type , snapshot ) {
120
- var data = this . _serializeData ( store , type , snapshot ) ,
121
- id = get ( snapshot , 'id' ) ;
120
+ var data = this . _serializeData ( store , type , snapshot ) ;
121
+ var id = get ( snapshot , 'id' ) ;
122
122
123
123
return this . ajax ( this . buildURL ( type . typeKey , id , snapshot ) , 'PUT' , {
124
124
data : data
125
125
} ) ;
126
126
} ,
127
127
128
128
_serializeData : function ( store , type , snapshot ) {
129
- var serializer = store . serializerFor ( type . typeKey ) ,
130
- pluralType = Ember . String . pluralize ( type . typeKey ) ,
131
- json = { } ;
129
+ var serializer = store . serializerFor ( type . typeKey ) ;
130
+ var pluralType = Ember . String . pluralize ( type . typeKey ) ;
131
+ var json = { } ;
132
132
133
133
json . data = serializer . serialize ( snapshot , { includeId : true } ) ;
134
134
if ( ! json . data . hasOwnProperty ( 'type' ) ) {
@@ -174,7 +174,7 @@ define("json-api-adapter",
174
174
175
175
pathForType : function ( type ) {
176
176
var decamelized = Ember . String . decamelize ( type ) ;
177
- return Ember . String . pluralize ( decamelized ) . replace ( / _ / g , '-' ) ;
177
+ return Ember . String . pluralize ( decamelized ) ;
178
178
}
179
179
} ) ;
180
180
@@ -282,13 +282,13 @@ define("json-api-adapter",
282
282
* Extract top-level "data" containing a single primary data
283
283
*/
284
284
extractArrayData : function ( data , payload ) {
285
- var type = data . length > 0 ? data [ 0 ] . type : null , serializer = this ;
285
+ var type = data . length > 0 ? data [ 0 ] . type : null ;
286
286
data . forEach ( function ( item ) {
287
287
if ( item . links ) {
288
- serializer . extractRelationships ( item . links , item ) ;
288
+ this . extractRelationships ( item . links , item ) ;
289
289
//delete data.links;
290
290
}
291
- } ) ;
291
+ } . bind ( this ) ) ;
292
292
293
293
payload [ type ] = data ;
294
294
} ,
@@ -297,19 +297,20 @@ define("json-api-adapter",
297
297
* Extract top-level "included" containing associated objects
298
298
*/
299
299
extractSideloaded : function ( sideloaded ) {
300
- var store = get ( this , 'store' ) , models = { } , serializer = this ;
300
+ var store = get ( this , 'store' ) ;
301
+ var models = { } ;
301
302
302
303
sideloaded . forEach ( function ( link ) {
303
304
var type = link . type ;
304
305
if ( link . links ) {
305
- serializer . extractRelationships ( link . links , link ) ;
306
+ this . extractRelationships ( link . links , link ) ;
306
307
}
307
308
delete link . type ;
308
309
if ( ! models [ type ] ) {
309
310
models [ type ] = [ ] ;
310
311
}
311
312
models [ type ] . push ( link ) ;
312
- } ) ;
313
+ } . bind ( this ) ) ;
313
314
314
315
this . pushPayload ( store , models ) ;
315
316
} ,
@@ -318,7 +319,7 @@ define("json-api-adapter",
318
319
* Parse the top-level "links" object.
319
320
*/
320
321
extractRelationships : function ( links , resource ) {
321
- var link , association , id , route , relationshipLink , cleanedRoute , linkKey ;
322
+ var link , association , id , route , relationshipLink , cleanedRoute ;
322
323
323
324
// Clear the old format
324
325
resource . links = { } ;
@@ -368,8 +369,8 @@ define("json-api-adapter",
368
369
// SERIALIZATION
369
370
370
371
serializeIntoHash : function ( hash , type , snapshot , options ) {
371
- var pluralType = Ember . String . pluralize ( type . typeKey ) ,
372
- data = this . serialize ( snapshot , options ) ;
372
+ var pluralType = Ember . String . pluralize ( type . typeKey ) ;
373
+ var data = this . serialize ( snapshot , options ) ;
373
374
if ( ! data . hasOwnProperty ( 'type' ) ) {
374
375
data . type = pluralType ;
375
376
}
@@ -395,9 +396,9 @@ define("json-api-adapter",
395
396
* Use "links" key
396
397
*/
397
398
serializeHasMany : function ( record , json , relationship ) {
398
- var attr = relationship . key ,
399
- type = this . keyForRelationship ( relationship . type . typeKey ) ,
400
- key = this . keyForRelationship ( attr ) ;
399
+ var attr = relationship . key ;
400
+ var type = this . keyForRelationship ( relationship . type . typeKey ) ;
401
+ var key = this . keyForRelationship ( attr ) ;
401
402
402
403
if ( relationship . kind === 'hasMany' ) {
403
404
json . links = json . links || { } ;
@@ -418,9 +419,10 @@ define("json-api-adapter",
418
419
}
419
420
420
421
function hasManyLink ( key , type , record , attr ) {
421
- var links = record . hasMany ( attr ) . mapBy ( 'id' ) || [ ] ,
422
- typeName = Ember . String . pluralize ( type ) ,
423
- linkages = [ ] , index , total ;
422
+ var links = record . hasMany ( attr ) . mapBy ( 'id' ) || [ ] ;
423
+ var typeName = Ember . String . pluralize ( type ) ;
424
+ var linkages = [ ] ;
425
+ var index , total ;
424
426
425
427
for ( index = 0 , total = links . length ; index < total ; ++ index ) {
426
428
linkages . push ( {
@@ -445,7 +447,8 @@ define("json-api-adapter",
445
447
}
446
448
function getLinkageIds ( linkage ) {
447
449
if ( Ember . isEmpty ( linkage ) ) { return null ; }
448
- var ids = [ ] , index , total ;
450
+ var ids = [ ] ;
451
+ var index , total ;
449
452
for ( index = 0 , total = linkage . length ; index < total ; ++ index ) {
450
453
ids . push ( normalizeLinkage ( linkage [ index ] ) ) ;
451
454
}
0 commit comments