File Coverage

blib/lib/Sieve/Generator/Element/Block.pm
Criterion Covered Total %
statement 25 25 100.0
branch n/a
condition 1 2 50.0
subroutine 5 5 100.0
pod 1 3 33.3
total 32 35 91.4


line stmt bran cond sub pod time code
1 1     1   11 use v5.36.0;
  1         3  
2             package Sieve::Generator::Element::Block 0.003;
3             # ABSTRACT: a Sieve block (a brace-delimited sequence of statements)
4              
5 1     1   579 use Moo;
  1         7592  
  1         6  
6             with 'Sieve::Generator::Element';
7              
8             #pod =head1 DESCRIPTION
9             #pod
10             #pod A block is the brace-delimited body of a Sieve C, C, or C
11             #pod clause. It contains an ordered list of things -- commands, nested
12             #pod conditionals, or comments -- each rendered on its own indented line.
13             #pod
14             #pod =attr things
15             #pod
16             #pod This attribute holds the list of things that make up the block body. Each
17             #pod may be an object doing L.
18             #pod
19             #pod =cut
20              
21             has _things => (is => 'ro', init_arg => 'things', required => 1);
22 33     33 1 32 sub things ($self) { $self->_things->@* }
  33         34  
  33         33  
  33         67  
23 4     4 0 5 sub children ($self) { $self->things }
  4         4  
  4         5  
  4         5  
24              
25 29     29 0 33 sub as_sieve ($self, $i = undef) {
  29         27  
  29         30  
  29         29  
26 29   50     40 $i //= 0;
27 29         44 my $class = ref $self;
28              
29 29         34 my $str = q{};
30 29         37 my $indent = q{ } x $i;
31 29         45 for my $thing ($self->things) {
32 31         87 my $text = $thing->as_sieve($i+1);
33              
34 31         59 $str .= "$text\n";
35             }
36              
37 29         78 return "{\n$str$indent}";
38             }
39              
40             1;
41              
42             __END__