| 1 | package Translate::Fluent::Elements::Base; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | 6 | ▶ | use Moo; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | |||||||||||||||
| 5 | 708 | ▶ | around BUILDARGS => sub { | ||||||||||||
|
Subroutine
__ANON__: called CC=9 SCAR=22.2
| |||||||||||||||
| 6 | 708 | my ($orig, $class, @args) = @_; | |||||||||||||
| 7 | |||||||||||||||
| 8 | 0 | ▶ | my %args = ref $args[0] ? %{ $args[0] } : @args; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 9 | |||||||||||||||
| 10 | 708 | for my $k (keys %args) { | |||||||||||||
| 11 | 1596 | my $val = delete $args{ $k }; | |||||||||||||
| 12 | |||||||||||||||
| 13 | 1596 | ▶ | if (ref $val eq 'HASH') { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 14 | |||||||||||||||
| 15 | 350 | my $res = Translate::Fluent::Elements->create( | |||||||||||||
| 16 | $k, $val | ||||||||||||||
| 17 | ); | ||||||||||||||
| 18 | |||||||||||||||
| 19 | 350 | ▶ | $val = $res if $res; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 20 | |||||||||||||||
| 21 | } elsif (ref $val eq 'ARRAY') { | ||||||||||||||
| 22 | 184 | my @items; | |||||||||||||
| 23 | 184 | for my $item ( @$val ) { | |||||||||||||
| 24 | 280 | my ($type) = keys %$item; | |||||||||||||
| 25 | my $itemval = ref $item->{$type} | ||||||||||||||
| 26 | ? $item->{$type} | ||||||||||||||
| 27 | 280 | ▶ | : { text => $item->{$type} }; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 28 | 280 | my $res = Translate::Fluent::Elements->create( | |||||||||||||
| 29 | $type => $itemval | ||||||||||||||
| 30 | ); | ||||||||||||||
| 31 | |||||||||||||||
| 32 | 280 | ▶ | push @items, $res ? $res : $item; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 33 | } | ||||||||||||||
| 34 | |||||||||||||||
| 35 | 184 | $val = \@items; | |||||||||||||
| 36 | } | ||||||||||||||
| 37 | |||||||||||||||
| 38 | 1596 | $args{ "\L$k" } = $val; | |||||||||||||
| 39 | } | ||||||||||||||
| 40 | |||||||||||||||
| 41 | 708 | return $class->$orig( %args ); | |||||||||||||
| 42 | 6 | }; | |||||||||||||
| 43 | |||||||||||||||
| 44 | 6 | 1; | |||||||||||||
| 45 | |||||||||||||||
| 46 | __END__ | ||||||||||||||