File Coverage

blib/lib/Sieve/Generator/Element/Document.pm
Criterion Covered Total %
statement 27 27 100.0
branch n/a
condition 2 2 100.0
subroutine 6 6 100.0
pod 1 3 33.3
total 36 38 94.7


line stmt bran cond sub pod time code
1 1     1   10 use v5.36.0;
  1         2  
2             package Sieve::Generator::Element::Document 0.003;
3             # ABSTRACT: a sequence of Sieve lines forming a complete script or blank line
4              
5 1     1   3 use Moo;
  1         15  
  1         4  
6             with 'Sieve::Generator::Element';
7              
8             #pod =head1 DESCRIPTION
9             #pod
10             #pod A document is an ordered sequence of things, and renders as a flat sequence of
11             #pod Sieve lines. It serves as the top-level container for a complete Sieve script
12             #pod (when constructed by L) or as an empty separator
13             #pod line (when constructed by L).
14             #pod
15             #pod =attr things
16             #pod
17             #pod This attribute holds the list of things that make up the document. Each may
18             #pod be a string or an object doing L.
19             #pod
20             #pod =cut
21              
22             has _things => (is => 'ro', init_arg => 'things', required => 1);
23 17     17 1 20 sub things ($self) { $self->_things->@* }
  17         17  
  17         15  
  17         47  
24 8     8 0 9 sub children ($self) { $self->things }
  8         8  
  8         9  
  8         12  
25              
26 9     9 0 755 sub as_sieve ($self, $i = undef) {
  9         12  
  9         10  
  9         9  
27 9   100     32 $i //= 0;
28              
29 9         25 my $str = q{};
30 9         17 my $indent = q{ } x $i;
31 9         17 for my $thing ($self->things) {
32 12         34 my $text = $thing->as_sieve($i);
33              
34 12         25 $str .= "$text\n";
35             }
36              
37 9         15 return $str;
38             }
39              
40 1     1   432 no Moo;
  1         2  
  1         2  
41             1;
42              
43             __END__