35 lines
592 B
Perl
35 lines
592 B
Perl
package LasTres::Words;
|
|
|
|
use v5.36.0;
|
|
|
|
use strict;
|
|
use warnings;
|
|
|
|
use feature 'signatures';
|
|
|
|
use Moo;
|
|
|
|
use Module::Pluggable search_path => ['LasTres::Word'],
|
|
instantiate => 'instance',
|
|
on_require_error => sub ($plugin, $error) {
|
|
die $error;
|
|
};
|
|
|
|
{
|
|
my %hash;
|
|
sub hash($self) {
|
|
if (!scalar %hash) {
|
|
my @words = $self->plugins();
|
|
for my $word (@words) {
|
|
$hash{$word->identifier} = $word;
|
|
}
|
|
}
|
|
return {%hash};
|
|
}
|
|
}
|
|
|
|
sub get($self, $identifier) {
|
|
return $self->hash->{$identifier};
|
|
}
|
|
1;
|