Skip to content

Commit 5ff48a6

Browse files
committed
Closes #51.
1 parent 1a32e0e commit 5ff48a6

File tree

8 files changed

+31
-22
lines changed

8 files changed

+31
-22
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- #30, #48 - DSCacheFactory integration
55
- #49 - DS.bindOne($scope, prop, resourceName, id)
66
- #50 - DS.bindAll($scope, prop, resourceName, query)
7+
- #51 - Allow baseUrl to be overridable at the method level
78
- #52 - DS.update(resourceName, id, attrs[, options]) (different from DS.save())
89
- #54 - Adding functionality to resources
910
- #56 - DS.updateAll(resourceName, attrs, params[, options])

Gruntfile.js

+8
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,14 @@ module.exports = function (grunt) {
292292
'bower_components/angular-cache/dist/angular-cache.js'
293293
],
294294
docs: ['guide/api']
295+
},
296+
{
297+
id: 'angular-data-mocks',
298+
title: 'angular-data-mocks',
299+
scripts: [
300+
'bower_components/angular-data-mocks/dist/angular-data-mocks.js'
301+
],
302+
docs: ['guide/api']
295303
}
296304
]
297305
}

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"devDependencies": {
2929
"angular": "~1.2.16",
3030
"angular-mocks": "~1.2.16",
31-
"angular-data-mocks": "0.1.0",
31+
"angular-data-mocks": "0.2.0",
3232
"angular-cache": "~3.0.0-beta.4",
3333
"observe-js": "~0.2.0"
3434
}

dist/angular-data.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -1589,7 +1589,7 @@ function DSHttpAdapterProvider() {
15891589
function find(resourceConfig, id, options) {
15901590
options = options || {};
15911591
return this.GET(
1592-
DSUtils.makePath(resourceConfig.baseUrl, resourceConfig.endpoint, id),
1592+
DSUtils.makePath(options.baseUrl || resourceConfig.baseUrl, resourceConfig.endpoint, id),
15931593
options
15941594
);
15951595
}
@@ -1602,23 +1602,23 @@ function DSHttpAdapterProvider() {
16021602
}
16031603
DSUtils.deepMixIn(options, params);
16041604
return this.GET(
1605-
DSUtils.makePath(resourceConfig.baseUrl, resourceConfig.endpoint),
1605+
DSUtils.makePath(options.baseUrl || resourceConfig.baseUrl, resourceConfig.endpoint),
16061606
options
16071607
);
16081608
}
16091609

16101610
function create(resourceConfig, attrs, options) {
16111611
options = options || {};
16121612
return this.POST(
1613-
DSUtils.makePath(resourceConfig.baseUrl, resourceConfig.endpoint),
1613+
DSUtils.makePath(options.baseUrl || resourceConfig.baseUrl, resourceConfig.endpoint),
16141614
defaults.serialize(attrs),
16151615
options
16161616
);
16171617
}
16181618

16191619
function update(resourceConfig, id, attrs, options) {
16201620
return this.PUT(
1621-
DSUtils.makePath(resourceConfig.baseUrl, resourceConfig.endpoint, id),
1621+
DSUtils.makePath(options.baseUrl || resourceConfig.baseUrl, resourceConfig.endpoint, id),
16221622
defaults.serialize(attrs),
16231623
options
16241624
);
@@ -1632,7 +1632,7 @@ function DSHttpAdapterProvider() {
16321632
}
16331633
DSUtils.deepMixIn(options, params);
16341634
return this.PUT(
1635-
DSUtils.makePath(resourceConfig.baseUrl, resourceConfig.endpoint),
1635+
DSUtils.makePath(options.baseUrl || resourceConfig.baseUrl, resourceConfig.endpoint),
16361636
defaults.serialize(attrs),
16371637
options
16381638
);
@@ -1641,7 +1641,7 @@ function DSHttpAdapterProvider() {
16411641
function destroy(resourceConfig, id, options) {
16421642
options = options || {};
16431643
return this.DEL(
1644-
DSUtils.makePath(resourceConfig.baseUrl, resourceConfig.endpoint, id),
1644+
DSUtils.makePath(options.baseUrl || resourceConfig.baseUrl, resourceConfig.endpoint, id),
16451645
options
16461646
);
16471647
}
@@ -1654,7 +1654,7 @@ function DSHttpAdapterProvider() {
16541654
}
16551655
DSUtils.deepMixIn(options, params);
16561656
return this.DEL(
1657-
DSUtils.makePath(resourceConfig.baseUrl, resourceConfig.endpoint),
1657+
DSUtils.makePath(options.baseUrl || resourceConfig.baseUrl, resourceConfig.endpoint),
16581658
options
16591659
);
16601660
}
@@ -1664,7 +1664,7 @@ function DSHttpAdapterProvider() {
16641664
module.exports = DSHttpAdapterProvider;
16651665

16661666
},{}],32:[function(require,module,exports){
1667-
var errorPrefix = 'DS.create(resourceName, attrs): ';
1667+
var errorPrefix = 'DS.create(resourceName, attrs[, options]): ';
16681668

16691669
/**
16701670
* @doc method
@@ -1675,7 +1675,7 @@ var errorPrefix = 'DS.create(resourceName, attrs): ';
16751675
*
16761676
* ## Signature:
16771677
* ```js
1678-
* DS.create(resourceName, attrs)
1678+
* DS.create(resourceName, attrs[, options])
16791679
* ```
16801680
*
16811681
* ## Example:

dist/angular-data.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/adapters/http.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ function DSHttpAdapterProvider() {
386386
function find(resourceConfig, id, options) {
387387
options = options || {};
388388
return this.GET(
389-
DSUtils.makePath(resourceConfig.baseUrl, resourceConfig.endpoint, id),
389+
DSUtils.makePath(options.baseUrl || resourceConfig.baseUrl, resourceConfig.endpoint, id),
390390
options
391391
);
392392
}
@@ -399,23 +399,23 @@ function DSHttpAdapterProvider() {
399399
}
400400
DSUtils.deepMixIn(options, params);
401401
return this.GET(
402-
DSUtils.makePath(resourceConfig.baseUrl, resourceConfig.endpoint),
402+
DSUtils.makePath(options.baseUrl || resourceConfig.baseUrl, resourceConfig.endpoint),
403403
options
404404
);
405405
}
406406

407407
function create(resourceConfig, attrs, options) {
408408
options = options || {};
409409
return this.POST(
410-
DSUtils.makePath(resourceConfig.baseUrl, resourceConfig.endpoint),
410+
DSUtils.makePath(options.baseUrl || resourceConfig.baseUrl, resourceConfig.endpoint),
411411
defaults.serialize(attrs),
412412
options
413413
);
414414
}
415415

416416
function update(resourceConfig, id, attrs, options) {
417417
return this.PUT(
418-
DSUtils.makePath(resourceConfig.baseUrl, resourceConfig.endpoint, id),
418+
DSUtils.makePath(options.baseUrl || resourceConfig.baseUrl, resourceConfig.endpoint, id),
419419
defaults.serialize(attrs),
420420
options
421421
);
@@ -429,7 +429,7 @@ function DSHttpAdapterProvider() {
429429
}
430430
DSUtils.deepMixIn(options, params);
431431
return this.PUT(
432-
DSUtils.makePath(resourceConfig.baseUrl, resourceConfig.endpoint),
432+
DSUtils.makePath(options.baseUrl || resourceConfig.baseUrl, resourceConfig.endpoint),
433433
defaults.serialize(attrs),
434434
options
435435
);
@@ -438,7 +438,7 @@ function DSHttpAdapterProvider() {
438438
function destroy(resourceConfig, id, options) {
439439
options = options || {};
440440
return this.DEL(
441-
DSUtils.makePath(resourceConfig.baseUrl, resourceConfig.endpoint, id),
441+
DSUtils.makePath(options.baseUrl || resourceConfig.baseUrl, resourceConfig.endpoint, id),
442442
options
443443
);
444444
}
@@ -451,7 +451,7 @@ function DSHttpAdapterProvider() {
451451
}
452452
DSUtils.deepMixIn(options, params);
453453
return this.DEL(
454-
DSUtils.makePath(resourceConfig.baseUrl, resourceConfig.endpoint),
454+
DSUtils.makePath(options.baseUrl || resourceConfig.baseUrl, resourceConfig.endpoint),
455455
options
456456
);
457457
}

src/datastore/async_methods/create.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var errorPrefix = 'DS.create(resourceName, attrs): ';
1+
var errorPrefix = 'DS.create(resourceName, attrs[, options]): ';
22

33
/**
44
* @doc method
@@ -9,7 +9,7 @@ var errorPrefix = 'DS.create(resourceName, attrs): ';
99
*
1010
* ## Signature:
1111
* ```js
12-
* DS.create(resourceName, attrs)
12+
* DS.create(resourceName, attrs[, options])
1313
* ```
1414
*
1515
* ## Example:

test/integration/datastore/async_methods/create.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
describe('DS.create(resourceName, attrs)', function () {
2-
var errorPrefix = 'DS.create(resourceName, attrs): ';
1+
describe('DS.create(resourceName, attrs[, options])', function () {
2+
var errorPrefix = 'DS.create(resourceName, attrs[, options]): ';
33

44
it('should throw an error when method pre-conditions are not met', function (done) {
55
DS.create('does not exist', 5).then(function () {

0 commit comments

Comments
 (0)