| 1 | package TUI::Dialogs::StrItem; | ||||||||||
| 2 | # ABSTRACT: Simple singly linked list node for dialog data | ||||||||||
| 3 | |||||||||||
| 4 | 11 | ▶ | use 5.010; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 11 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 11 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 11 | our $VERSION = '2.000002'; | |||||||||
| 9 | 11 | $VERSION =~ tr/_//d; | |||||||||
| 10 | 11 | our $AUTHORITY = 'cpan:BRICKPOOL'; | |||||||||
| 11 | |||||||||||
| 12 | 11 | ▶ | use Exporter 'import'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 11 | our @EXPORT = qw( | |||||||||
| 14 | TSItem | ||||||||||
| 15 | new_TSItem | ||||||||||
| 16 | ); | ||||||||||
| 17 | |||||||||||
| 18 | 11 | ▶ | use Devel::StrictMode; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | 11 | ▶ | use if STRICT => 'Hash::Util'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | 11 | ▶ | use TUI::toolkit qw( :utils ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | 11 | ▶ | use TUI::toolkit::Types qw( | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 22 | Maybe | ||||||||||
| 23 | :is | ||||||||||
| 24 | :types | ||||||||||
| 25 | 11 | ); | |||||||||
| 26 | |||||||||||
| 27 | sub TSItem() { __PACKAGE__ } | ||||||||||
| 28 | 0 | ▶ | sub new_TSItem { __PACKAGE__->from(@_) } | ||||||||
|
Subroutine
new_TSItem: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 29 | |||||||||||
| 30 | # public attributes | ||||||||||
| 31 | 11 | ▶ | our %HAS; BEGIN { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=1.2
| |||||||||||
| 32 | %HAS = ( | ||||||||||
| 33 | 0 | ▶ | value => sub { '' }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 34 | 0 | ▶ | next => sub { undef }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 35 | 11 | ); | |||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | 3 | ▶ | sub new { # \$item (%args) | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 39 | 3 | state $sig = signature( | |||||||||
| 40 | method => 1, | ||||||||||
| 41 | named => [ | ||||||||||
| 42 | value => Str, | ||||||||||
| 43 | next => Maybe[Object], | ||||||||||
| 44 | ], | ||||||||||
| 45 | ); | ||||||||||
| 46 | 3 | my ( $class, $self ) = $sig->( @_ ); | |||||||||
| 47 | 3 | bless $self, $class; | |||||||||
| 48 | 3 | Hash::Util::lock_keys( %$self ) if STRICT; | |||||||||
| 49 | 3 | return $self; | |||||||||
| 50 | } | ||||||||||
| 51 | |||||||||||
| 52 | 0 | ▶ | sub from { # $item ($aValue, $aNext|undef) | ||||||||
|
Subroutine
from: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 53 | 0 | state $sig = signature( | |||||||||
| 54 | method => 1, | ||||||||||
| 55 | pos => [Str, Maybe[Object]], | ||||||||||
| 56 | ); | ||||||||||
| 57 | 0 | my ( $class, @args ) = $sig->( @_ ); | |||||||||
| 58 | 0 | return $class->new( value => $args[0], next => $args[1] ); | |||||||||
| 59 | } | ||||||||||
| 60 | |||||||||||
| 61 | 11 | ▶ | my $mk_accessors = sub { | ||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.1
| |||||||||||
| 62 | 11 | my ( $pkg ) = @_; | |||||||||
| 63 | 11 | ▶ | assert ( @_ == 1 ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 64 | 11 | ▶ | assert ( defined $pkg ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 65 | 11 | ▶ | no strict 'refs'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 66 | 11 | my %HAS = %{"${pkg}::HAS"}; | |||||||||
| 67 | 11 | for my $field ( keys %HAS ) { | |||||||||
| 68 | 22 | my $full_name = "${pkg}::$field"; | |||||||||
| 69 | 6 | ▶ | *$full_name = sub { | ||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=12.0
| |||||||||||
| 70 | 6 | ▶ | assert ( is_Object $_[0] ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 71 | 6 | ▶ | if ( @_ > 1 ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 72 | 0 | $_[0]->{$field} = $_[1]; | |||||||||
| 73 | } | ||||||||||
| 74 | 6 | $_[0]->{$field}; | |||||||||
| 75 | 22 | }; | |||||||||
| 76 | } | ||||||||||
| 77 | 11 | }; | |||||||||
| 78 | |||||||||||
| 79 | 11 | __PACKAGE__->$mk_accessors(); | |||||||||
| 80 | |||||||||||
| 81 | 11 | 1; | |||||||||
| 82 | |||||||||||
| 83 | __END__ | ||||||||||