Repo.pm 717B

1234567891011121314151617181920212223242526272829303132333435
  1. package SugarTrail::Repo;
  2. # provide access to STM objects
  3. #
  4. # * load_master()
  5. use strict;
  6. use warnings;
  7. use Carp;
  8. use helper;
  9. use SugarTrail::Template::Master;
  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_master {
  21. my $self = shift;
  22. my $args = { @_ };
  23. my $master = SugarTrail::Template::Master->new();
  24. $master->{text} = $self->load_text(source => $args->{source})
  25. or return;
  26. $master->{source} = $args->{source};
  27. return $master;
  28. }
  29. 1;