| 1 | package Reaction::UI::ViewPort::Field::String::Fragment; | ||||||||||
| 2 | |||||||||||
| 3 | 4 | ▶ | use Reaction::Class; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 4 | ▶ | use MooseX::Types::Moose qw/Int/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 4 | extends 'Reaction::UI::ViewPort::Field::String'; | |||||||||
| 6 | |||||||||||
| 7 | has max_length => ( | ||||||||||
| 8 | is => 'rw', | ||||||||||
| 9 | isa => Int, | ||||||||||
| 10 | required => 1, | ||||||||||
| 11 | 0 | ▶ | default => sub { 80 } | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 12 | 4 | ); | |||||||||
| 13 | |||||||||||
| 14 | 0 | ▶ | sub _build_layout { 'field/string' }; | ||||||||
|
Subroutine
_build_layout: not called CC=1 SCAR=6.9
| |||||||||||
| 15 | |||||||||||
| 16 | 0 | ▶ | around _build_value_string => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||
| 17 | 0 | my $super = shift; | |||||||||
| 18 | 0 | my $self = $_[0]; | |||||||||
| 19 | 0 | my $string = $super->(@_); | |||||||||
| 20 | 0 | my $max_len = $self->max_length; | |||||||||
| 21 | 0 | ▶ | if(length($string) > $max_len){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 22 | 0 | $string = join('', substr( $string, 0, $max_len - 3 ), '...'); | |||||||||
| 23 | } | ||||||||||
| 24 | 0 | return $string; | |||||||||
| 25 | 4 | }; | |||||||||
| 26 | |||||||||||
| 27 | 4 | 1; | |||||||||
| 28 | |||||||||||
| 29 | __END__; | ||||||||||