1 package App::Commentry::CommentSet;
3 use aliased 'App::Commentry::Comment';
7 has base_dir => (is => 'ro', required => 1);
8 has path => (is => 'ro', required => 1);
10 has _json => (is => 'lazy');
12 sub _build__json { JSON->new->utf8->pretty }
14 has _members => (is => 'lazy');
18 my $file = join('/', $self->base_dir, $self->path).'.json';
19 return [] unless -e $file;
21 open my $in, '<', $file
22 or die "Couldn't open ${file}: $!";
25 [ map Comment->new($_), @{$self->_json->decode($text)} ];
34 my ($self, $mapping) = @_;
35 require App::Commentry::MappedSet;
36 App::Commentry::MappedSet->new(source => $self, mapping => $mapping);