File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change 2
2
use Perl6::Documentable;
3
3
4
4
class Perl6::Documentable::Registry {
5
- has @ ! documentables ;
5
+ has @ . documentables ;
6
+ has Bool $ . composed = False ;
7
+ has % ! cache ;
8
+ has % ! grouped-by
6
9
method add-new (* % args ) {
10
+ die " Cannot add something to a composed registry" if $ . composed ;
7
11
@ ! documentables . push : Perl6::Documentable. new (| % args );
8
12
1 ;
9
13
}
14
+ method compose () {
15
+ $ ! composed = True ;
16
+ }
17
+ method grouped-by (Str $ what ) {
18
+ die " You need to compose this registry first" unless $ . composed ;
19
+ % ! grouped-by ||= @ ! documentables . classify (*. " $ what" ());
20
+ }
21
+ method lookup (Str $ what , Str : $ by ! ) {
22
+ unless % ! cache . exists ($ by ) {
23
+ for @ ! documentables -> $ d {
24
+ % ! cache {$ by }{$ d . " $ by" ()}. push : $ d ;
25
+ }
26
+ }
27
+ % ! cache {$ by }{$ d };
28
+ }
10
29
}
You can’t perform that action at this time.
0 commit comments