File Coverage

blib/lib/Translate/Fluent/Elements/InlineExpression.pm
Criterion Covered Total %
statement 6 6 100.0
branch 2 2 100.0
condition 1 3 33.3
subroutine 2 2 100.0
pod 1 1 100.0
total 12 14 85.7


line stmt bran cond sub pod time code
1             package Translate::Fluent::Elements::InlineExpression;
2              
3 6     6   41 use Moo;
  6         11  
  6         33  
4             extends 'Translate::Fluent::Elements::Base';
5              
6             has [qw(
7             string_literal
8             number_literal
9             function_reference
10             message_reference
11             term_reference
12             variable_reference
13             inline_placeable
14             )] => (
15             is => 'ro',
16             default => sub { undef },
17             );
18              
19             around BUILDARGS => sub {
20             my ($orig, $class, %args) = @_;
21              
22             $args{string_literal} = delete $args{ StringLiteral };
23             $args{number_literal} = delete $args{ NumberLiteral };
24             $args{function_reference} = delete $args{ FunctionReference };
25             $args{message_reference} = delete $args{ MessageReference };
26             $args{term_reference} = delete $args{ TermReference };
27             $args{variable_reference} = delete $args{ VariableReference };
28             $args{inline_placeable} = delete $args{ InlinePlaceable };
29              
30             $class->$orig( %args );
31             };
32              
33             sub translate {
34 39     39 1 54 my ($self, $variables) = @_;
35              
36 39   33     300 my $part
37             = $self->string_literal
38             || $self->number_literal
39             || $self->function_reference
40             || $self->message_reference
41             || $self->term_reference
42             || $self->variable_reference
43             || $self->inline_placeable;
44              
45 39 100       126 return ref $part ? $part->translate( $variables ) : $part;
46            
47             }
48              
49             1;
50             __END__