Repo.pm 661B

1234567891011121314151617181920212223242526272829303132333435
  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. use SugarTrail::STM;
  10. # initialize repo
  11. sub new {
  12. my $class = shift;
  13. my $args = { @_ };
  14. exists($args->{type}) or $args->{type} = 'SugarTrail::Repo::Filesystem';
  15. $class = $args->{type};
  16. #TODO: remove use fail
  17. use SugarTrail::Repo::Filesystem;
  18. return $class->new(%$args);
  19. }
  20. sub load_stm {
  21. my $self = shift;
  22. my $args = { @_ };
  23. my $stm = SugarTrail::STM->new();
  24. $stm->{text} = $self->load_text(stm => $args->{stm})
  25. or return;
  26. $stm->{stm} = $args->{stm};
  27. return $stm;
  28. }
  29. 1;