LasTres/lib/LasTres/Planets.pm

33 lines
532 B
Perl

package LasTres::Planets;
use v5.36.0;
use strict;
use warnings;
use feature 'signatures';
use Moo;
use Module::Pluggable search_path => ['LasTres::Planet'],
instantiate => 'instance',
on_require_error => sub ($plugin, $error) {
die $error;
};
has hash => (
is => 'rw',
lazy => 1,
builder => \&_build_hash,
);
sub _build_hash($self) {
my @planets = $self->plugins();
my %hash;
for my $planet (@planets) {
$hash{$planet->identifier} = $planet;
}
return \%hash;
}
1;