File Coverage

blib/lib/WWW/Shopify/Liquid/Tag/Unless.pm
Criterion Covered Total %
statement 14 22 63.6
branch 7 20 35.0
condition 2 3 66.6
subroutine 4 5 80.0
pod 0 2 0.0
total 27 52 51.9


line stmt bran cond sub pod time code
1             #!/usr/bin/perl
2 21     21   10608 use strict;
  21         42  
  21         763  
3 21     21   104 use warnings;
  21         34  
  21         762  
4              
5             package WWW::Shopify::Liquid::Tag::Unless;
6 21     21   96 use base 'WWW::Shopify::Liquid::Tag::If';
  21         29  
  21         9478  
7            
8             sub render {
9 3     3 0 4 my ($self, $hash) = @_;
10 3 50       17 my $arguments = $self->is_processed($self->{arguments}->[0]) ? $self->{arguments}->[0] : $self->{arguments}->[0]->render($hash);
11 3 100       9 my $path = $self->{!$arguments ? 'true_path' : 'false_path'};
12 3 100 66     28 $path = $path->render($hash) if $path && !$self->is_processed($path);
13 3 100       9 return defined $path ? $path : '';
14             }
15              
16             sub optimize {
17 0     0 0   my ($self, $hash) = @_;
18 0 0         $self->{arguments}->[0] = $self->{arguments}->[0]->optimize($hash) if !$self->is_processed($self->{arguments}->[0]);
19 0 0         if ($self->is_processed($self->{arguments}->[0])) {
20 0 0         my $path = $self->{!$self->{arguments}->[0] ? 'true_path' : 'false_path'};
21 0 0         return $self->is_processed($path) ? $path : $path->optimize($hash);
22             }
23 0 0         $self->{false_path} = $self->{false_path}->optimize($hash) if !$self->is_processed($self->{false_path});
24 0 0         $self->{true_path} = $self->{true_path}->optimize($hash) if !$self->is_processed($self->{true_path});
25 0           return $self;
26             }
27              
28             1;