@@ -4547,20 +4547,29 @@ function defineResource(definition) {
45474547 def . getEndpoint = function ( attrs , options ) {
45484548 var parent = this . parent ;
45494549 var parentKey = this . parentKey ;
4550+ var item ;
4551+ var endpoint ;
45504552 options = options || { } ;
4551- if ( ! ( 'nested' in options ) ) {
4552- options . nested = true ;
4553- }
4554- if ( parent && parentKey && definitions [ parent ] && options . nested ) {
4553+ options . params = options . params || { } ;
4554+ if ( parent && parentKey && definitions [ parent ] && options . params [ parentKey ] !== false ) {
4555+ if ( DS . utils . isNumber ( attrs ) || DS . utils . isString ( attrs ) ) {
4556+ item = DS . get ( this . name , attrs ) ;
4557+ }
45554558 if ( DS . utils . isObject ( attrs ) && parentKey in attrs ) {
4556- return DS . utils . makePath ( definitions [ parent ] . getEndpoint ( attrs , options ) , attrs [ parentKey ] , this . endpoint ) ;
4557- } else if ( ( DS . utils . isNumber ( attrs ) || DS . utils . isString ( attrs ) ) && DS . get ( this . name , attrs ) && parentKey in DS . get ( this . name , attrs ) ) {
4558- return DS . utils . makePath ( definitions [ parent ] . getEndpoint ( attrs , options ) , DS . get ( this . name , attrs ) [ parentKey ] , this . endpoint ) ;
4559- } else if ( options && options . parentKey ) {
4560- return DS . utils . makePath ( definitions [ parent ] . getEndpoint ( attrs , options ) , options . parentKey , this . endpoint ) ;
4559+ delete options . params [ parentKey ] ;
4560+ endpoint = DS . utils . makePath ( definitions [ parent ] . getEndpoint ( attrs , options ) , attrs [ parentKey ] , this . endpoint ) ;
4561+ } else if ( item && parentKey in item ) {
4562+ delete options . params [ parentKey ] ;
4563+ endpoint = DS . utils . makePath ( definitions [ parent ] . getEndpoint ( attrs , options ) , item [ parentKey ] , this . endpoint ) ;
4564+ } else if ( options && options . params [ parentKey ] ) {
4565+ endpoint = DS . utils . makePath ( definitions [ parent ] . getEndpoint ( attrs , options ) , options . params [ parentKey ] , this . endpoint ) ;
4566+ delete options . params [ parentKey ] ;
45614567 }
45624568 }
4563- return this . endpoint ;
4569+ if ( options . params [ parentKey ] === false ) {
4570+ delete options . params [ parentKey ] ;
4571+ }
4572+ return endpoint || this . endpoint ;
45644573 } ;
45654574
45664575 // Remove this in v0.11.0 and make a breaking change notice
0 commit comments