1
1
/**
2
2
* @author Jason Dobry <[email protected] >
3
3
* @file js-data-http.js
4
- * @version 1.0.0-alpha.2 - Homepage <http://www.js-data.iojs-data-http/>
4
+ * @version 1.0.0-alpha.3 - Homepage <http://www.js-data.iojs-data-http/>
5
5
* @copyright (c) 2014 Jason Dobry
6
6
* @license MIT <https://github.com/js-data/js-data-http/blob/master/LICENSE>
7
7
*
@@ -1408,7 +1408,7 @@ function Defaults() {
1408
1408
1409
1409
var defaultsPrototype = Defaults . prototype ;
1410
1410
1411
- defaultsPrototype . queryTransform = function ( resourceName , params ) {
1411
+ defaultsPrototype . queryTransform = function ( resourceConfig , params ) {
1412
1412
return params ;
1413
1413
} ;
1414
1414
@@ -1428,11 +1428,11 @@ defaultsPrototype.error = console ? function (a, b) {
1428
1428
} : function ( ) {
1429
1429
} ;
1430
1430
1431
- defaultsPrototype . deserialize = function ( resourceName , data ) {
1431
+ defaultsPrototype . deserialize = function ( resourceConfig , data ) {
1432
1432
return data ? ( 'data' in data ? data . data : data ) : data ;
1433
1433
} ;
1434
1434
1435
- defaultsPrototype . serialize = function ( resourceName , data ) {
1435
+ defaultsPrototype . serialize = function ( resourceConfig , data ) {
1436
1436
return data ;
1437
1437
} ;
1438
1438
@@ -1526,7 +1526,7 @@ dsHttpAdapterPrototype.find = function (resourceConfig, id, options) {
1526
1526
_this . getIdPath ( resourceConfig , options , id ) ,
1527
1527
options
1528
1528
) . then ( function ( data ) {
1529
- return ( options . deserialize ? options . deserialize : _this . defaults . deserialize ) ( resourceConfig . name , data ) ;
1529
+ return ( options . deserialize ? options . deserialize : _this . defaults . deserialize ) ( resourceConfig , data ) ;
1530
1530
} ) ;
1531
1531
} ;
1532
1532
@@ -1535,14 +1535,14 @@ dsHttpAdapterPrototype.findAll = function (resourceConfig, params, options) {
1535
1535
options = options || { } ;
1536
1536
options . params = options . params || { } ;
1537
1537
if ( params ) {
1538
- params = _this . defaults . queryTransform ( resourceConfig . name , params ) ;
1538
+ params = _this . defaults . queryTransform ( resourceConfig , params ) ;
1539
1539
deepMixIn ( options . params , params ) ;
1540
1540
}
1541
1541
return _this . GET (
1542
1542
_this . getAllPath ( resourceConfig , options ) ,
1543
1543
options
1544
1544
) . then ( function ( data ) {
1545
- return ( options . deserialize ? options . deserialize : _this . defaults . deserialize ) ( resourceConfig . name , data ) ;
1545
+ return ( options . deserialize ? options . deserialize : _this . defaults . deserialize ) ( resourceConfig , data ) ;
1546
1546
} ) ;
1547
1547
} ;
1548
1548
@@ -1551,10 +1551,10 @@ dsHttpAdapterPrototype.create = function (resourceConfig, attrs, options) {
1551
1551
options = options || { } ;
1552
1552
return _this . POST (
1553
1553
makePath ( options . basePath || this . defaults . basePath || resourceConfig . basePath , resourceConfig . getEndpoint ( attrs , options ) ) ,
1554
- options . serialize ? options . serialize ( resourceConfig . name , attrs ) : _this . defaults . serialize ( resourceConfig . name , attrs ) ,
1554
+ options . serialize ? options . serialize ( resourceConfig , attrs ) : _this . defaults . serialize ( resourceConfig , attrs ) ,
1555
1555
options
1556
1556
) . then ( function ( data ) {
1557
- return ( options . deserialize ? options . deserialize : _this . defaults . deserialize ) ( resourceConfig . name , data ) ;
1557
+ return ( options . deserialize ? options . deserialize : _this . defaults . deserialize ) ( resourceConfig , data ) ;
1558
1558
} ) ;
1559
1559
} ;
1560
1560
@@ -1563,10 +1563,10 @@ dsHttpAdapterPrototype.update = function (resourceConfig, id, attrs, options) {
1563
1563
options = options || { } ;
1564
1564
return _this . PUT (
1565
1565
_this . getIdPath ( resourceConfig , options , id ) ,
1566
- options . serialize ? options . serialize ( resourceConfig . name , attrs ) : _this . defaults . serialize ( resourceConfig . name , attrs ) ,
1566
+ options . serialize ? options . serialize ( resourceConfig , attrs ) : _this . defaults . serialize ( resourceConfig , attrs ) ,
1567
1567
options
1568
1568
) . then ( function ( data ) {
1569
- return ( options . deserialize ? options . deserialize : _this . defaults . deserialize ) ( resourceConfig . name , data ) ;
1569
+ return ( options . deserialize ? options . deserialize : _this . defaults . deserialize ) ( resourceConfig , data ) ;
1570
1570
} ) ;
1571
1571
} ;
1572
1572
@@ -1575,15 +1575,15 @@ dsHttpAdapterPrototype.updateAll = function (resourceConfig, attrs, params, opti
1575
1575
options = options || { } ;
1576
1576
options . params = options . params || { } ;
1577
1577
if ( params ) {
1578
- params = _this . defaults . queryTransform ( resourceConfig . name , params ) ;
1578
+ params = _this . defaults . queryTransform ( resourceConfig , params ) ;
1579
1579
deepMixIn ( options . params , params ) ;
1580
1580
}
1581
1581
return this . PUT (
1582
1582
_this . getAllPath ( resourceConfig , options ) ,
1583
- options . serialize ? options . serialize ( resourceConfig . name , attrs ) : _this . defaults . serialize ( resourceConfig . name , attrs ) ,
1583
+ options . serialize ? options . serialize ( resourceConfig , attrs ) : _this . defaults . serialize ( resourceConfig , attrs ) ,
1584
1584
options
1585
1585
) . then ( function ( data ) {
1586
- return ( options . deserialize ? options . deserialize : _this . defaults . deserialize ) ( resourceConfig . name , data ) ;
1586
+ return ( options . deserialize ? options . deserialize : _this . defaults . deserialize ) ( resourceConfig , data ) ;
1587
1587
} ) ;
1588
1588
} ;
1589
1589
@@ -1594,7 +1594,7 @@ dsHttpAdapterPrototype.destroy = function (resourceConfig, id, options) {
1594
1594
_this . getIdPath ( resourceConfig , options , id ) ,
1595
1595
options
1596
1596
) . then ( function ( data ) {
1597
- return ( options . deserialize ? options . deserialize : _this . defaults . deserialize ) ( resourceConfig . name , data ) ;
1597
+ return ( options . deserialize ? options . deserialize : _this . defaults . deserialize ) ( resourceConfig , data ) ;
1598
1598
} ) ;
1599
1599
} ;
1600
1600
@@ -1603,14 +1603,14 @@ dsHttpAdapterPrototype.destroyAll = function (resourceConfig, params, options) {
1603
1603
options = options || { } ;
1604
1604
options . params = options . params || { } ;
1605
1605
if ( params ) {
1606
- params = _this . defaults . queryTransform ( resourceConfig . name , params ) ;
1606
+ params = _this . defaults . queryTransform ( resourceConfig , params ) ;
1607
1607
deepMixIn ( options . params , params ) ;
1608
1608
}
1609
1609
return this . DEL (
1610
1610
_this . getAllPath ( resourceConfig , options ) ,
1611
1611
options
1612
1612
) . then ( function ( data ) {
1613
- return ( options . deserialize ? options . deserialize : _this . defaults . deserialize ) ( resourceConfig . name , data ) ;
1613
+ return ( options . deserialize ? options . deserialize : _this . defaults . deserialize ) ( resourceConfig , data ) ;
1614
1614
} ) ;
1615
1615
} ;
1616
1616
0 commit comments