| 1 | package Translate::Fluent::Elements::TermReference; | ||||||||||
| 2 | |||||||||||
| 3 | 6 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 6 | extends 'Translate::Fluent::Elements::Base'; | |||||||||
| 5 | |||||||||||
| 6 | has [qw( | ||||||||||
| 7 | identifier | ||||||||||
| 8 | attribute_accessor | ||||||||||
| 9 | call_arguments | ||||||||||
| 10 | )] => ( | ||||||||||
| 11 | is => 'ro', | ||||||||||
| 12 | 0 | ▶ | default => sub { undef }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 13 | 6 | ); | |||||||||
| 14 | |||||||||||
| 15 | 20 | ▶ | around BUILDARGS => sub { | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 16 | 20 | my ($orig, $class, %args) = @_; | |||||||||
| 17 | |||||||||||
| 18 | 20 | $args{identifier} = delete $args{ Identifier }; | |||||||||
| 19 | 20 | $args{attribute_accessor} = delete $args{ AttributeAccessor }; | |||||||||
| 20 | 20 | $args{call_arguments} = delete $args{ CallArguments }; | |||||||||
| 21 | |||||||||||
| 22 | 20 | $class->$orig( %args ); | |||||||||
| 23 | 6 | }; | |||||||||
| 24 | |||||||||||
| 25 | 15 | ▶ | sub translate { | ||||||||
|
Subroutine
translate: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||
| 26 | 15 | my ($self, $variables) = @_; | |||||||||
| 27 | |||||||||||
| 28 | 15 | my $res = $variables->{__resourceset}->get_term( $self->identifier ); | |||||||||
| 29 | 15 | ▶ | return unless $res; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 30 | |||||||||||
| 31 | 15 | ▶ | if ($self->attribute_accessor) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 32 | 9 | $res = $res->get_attribute_resource( | |||||||||
| 33 | $self->attribute_accessor->identifier | ||||||||||
| 34 | ); | ||||||||||
| 35 | } | ||||||||||
| 36 | |||||||||||
| 37 | 15 | ▶ | return unless $res; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 38 | |||||||||||
| 39 | my $vars = $self->call_arguments | ||||||||||
| 40 | 9 | ? { %{ $self->call_arguments->to_variables }, | |||||||||
| 41 | __resourceset => $variables->{__resourceset} | ||||||||||
| 42 | } | ||||||||||
| 43 | 15 | ▶ | : $variables; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 44 | |||||||||||
| 45 | 15 | return $res->translate( $vars ); | |||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | 6 | 1; | |||||||||
| 49 | __END__ | ||||||||||