Data.pm 585 B

123456789101112131415161718192021222324252627282930
  1. package Trog::Data;
  2. use v5.36;
  3. use re '/aa';
  4. #It's just a factory
  5. =head1 Trog::Data
  6. This is a data model factory.
  7. =head2 Trog::Data->new(Trog::Config) = $handle
  8. Returns a new Trog::Data::* class appropriate to what is configured in the Trog::Config object passed.
  9. =cut
  10. sub new ( $class, $config ) {
  11. state $datamodule;
  12. return $datamodule if $datamodule;
  13. my $module = "Trog::Data::" . $config->param('general.data_model');
  14. my $req = $module;
  15. $req =~ s/::/\//g;
  16. require "$req.pm";
  17. $datamodule = $module->new($config);
  18. return $datamodule;
  19. }
  20. 1;