add json file
[scpubgit/Commentry.git] / lib / App / Commentry / CommentStore.pm
1 package App::Commentry::CommentStore;
2
3 use aliased 'App::Commentry::CommentSet';
4 use Moo;
5
6 has base_dir => (is => 'ro', required => 1);
7
8 has _cache => (is => 'ro', default => sub { {} });
9
10 sub get {
11   my ($self, $proto) = @_;
12   my $path = $proto->{path} or die "->get requires a path key";
13   $self->_cache->{$path} ||= do {
14     CommentSet->new(base_dir => $self->base_dir, path => $path)
15   };
16 }
17
18 1;