Skip to content

Commit 201b588

Browse files
author
Brian Le
committed
Add a getter to get all definitions
1 parent d01c325 commit 201b588

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ internals.Registry = class {
4747
this._definitions = new internals.Definitions();
4848
}
4949

50+
get definitions() {
51+
52+
return [].concat(...this._definitions.values());
53+
}
54+
5055
add(...definitions) {
5156

5257
definitions = Schemas.definitions.attempt(definitions);

tests/index.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,27 @@ describe('registry()', () => {
2222
});
2323
});
2424

25+
describe('definitions', () => {
26+
27+
it('should return all the definitions', () => {
28+
29+
const registry = Ruby.registry();
30+
registry.add({
31+
name: 'simple',
32+
}, {
33+
name: 'complex',
34+
args: ['arg1', 'arg2'],
35+
});
36+
37+
const definitions = [
38+
{ name: 'simple' },
39+
{ name: 'complex', args: [{ name: 'arg1' }, { name: 'arg2' }] },
40+
];
41+
42+
expect(Bone.equal(registry.definitions, definitions)).toBe(true);
43+
});
44+
});
45+
2546
describe('match()', () => {
2647

2748
it('should return null for mismatching prefixes', () => {

0 commit comments

Comments
 (0)