has 'text' => (
is => 'rw',
isa => 'ArrayRef[Str]',
+ predicate => 'has_text',
);
# Source. This is where we read in the witness, if not from a
has 'path' => (
is => 'rw',
isa => 'ArrayRef[Text::Tradition::Collation::Reading]',
+ predicate => 'has_path',
);
sub BUILD {
}
}
+# If the text is not present, and the path is, and this is a 'get'
+# request, generate text from path.
+around text => sub {
+ my $orig = shift;
+ my $self = shift;
+
+ if( $self->has_path && !$self->has_text && !@_ ) {
+ my @words = map { $_->label } @{$self->path};
+ $self->$orig( \@words );
+ }
+
+ $self->$orig( @_ );
+};
+
no Moose;
__PACKAGE__->meta->make_immutable;