| 1 | package Translate::Fluent::Elements::MessageReference; | ||||||||||
| 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 | )] => ( | ||||||||||
| 10 | is => 'ro', | ||||||||||
| 11 | 0 | ▶ | default => sub { undef }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 12 | 6 | ); | |||||||||
| 13 | |||||||||||
| 14 | 16 | ▶ | around BUILDARGS => sub { | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 16 | my ($orig, $class, %args) = @_; | |||||||||
| 16 | |||||||||||
| 17 | 16 | $args{identifier} = delete $args{ Identifier }; | |||||||||
| 18 | 16 | $args{attribute_accessor} = delete $args{ AttributeAccessor }; | |||||||||
| 19 | |||||||||||
| 20 | 16 | $class->$orig( %args ); | |||||||||
| 21 | 6 | }; | |||||||||
| 22 | |||||||||||
| 23 | 6 | ▶ | sub translate { | ||||||||
|
Subroutine
translate: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||
| 24 | 6 | my ($self, $variables) = @_; | |||||||||
| 25 | |||||||||||
| 26 | 6 | my $message = $variables->{__resourceset}->get_message( $self->identifier ); | |||||||||
| 27 | 6 | ▶ | return unless $message; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 28 | |||||||||||
| 29 | 6 | ▶ | if ($self->attribute_accessor) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 30 | 4 | $message = $message->get_attribute_resource( | |||||||||
| 31 | $self->attribute_accessor->identifier | ||||||||||
| 32 | ); | ||||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | 6 | ▶ | return unless $message; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 36 | |||||||||||
| 37 | # Not sure if this should be called with no variables | ||||||||||
| 38 | # or with the variables the parent was called with | ||||||||||
| 39 | # so going with the later for now. | ||||||||||
| 40 | 6 | return $message->translate( $variables ); | |||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | 6 | 1; | |||||||||
| 44 | __END__ | ||||||||||