Skip to content

Commit bfea54d

Browse files
committed
Add Scope#scope method
The `Model` class has a `scope()` method to return the scope for it. It would be nice to be able to pass in either a model or a scope to the a function and use the `scope()` method to cast it to a scope regardless, instead of doing type detection.
1 parent 98cce59 commit bfea54d

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/scope.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ export default class Scope {
9595
return this;
9696
}
9797

98+
scope() : Scope {
99+
return this;
100+
}
101+
98102
asQueryParams() : Object {
99103
let qp = {};
100104

test/unit/scope-test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ describe('Scope', function() {
118118
});
119119
});
120120

121+
describe('#scope()', function() {
122+
it('returns itself', function() {
123+
expect(scope.scope()).to.equal(scope)
124+
})
125+
})
126+
121127
describe('#asQueryParams()', function() {
122128
it('transforms all scoping criteria into a jsonapi-compatible query param object', function() {
123129
scope

0 commit comments

Comments
 (0)