Repo.pm 613B

123456789101112131415161718192021222324252627282930313233
  1. package SugarTrail::Repo;
  2. # provide access to STM objects
  3. #
  4. # * load_stm()
  5. use strict;
  6. use warnings;
  7. use Carp;
  8. use helper;
  9. # initialize repo
  10. sub new {
  11. my $class = shift;
  12. my $args = { @_ };
  13. exists($args->{type}) or $args->{type} = 'SugarTrail::Repo::Filesystem';
  14. $class = $args->{type};
  15. #TODO: remove use fail
  16. use SugarTrail::Repo::Filesystem;
  17. return $class->new(%$args);
  18. }
  19. sub load_stm {
  20. my $self = shift;
  21. my $args = { @_ };
  22. my $stm = {};
  23. $stm->{text} = $self->load_text(stm => $args->{stm})
  24. or return;
  25. return bless $stm, 'SugarTrail::STM';
  26. }
  27. 1;