| 1 | package MooX::ShortHas; | ||||||||||
| 2 | |||||||||||
| 3 | 3 | ▶ | use strictures 2; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 2 | our $VERSION = '1.202040'; # VERSION | |||||||||
| 6 | |||||||||||
| 7 | # ABSTRACT: shortcuts for common Moo has attribute configurations | ||||||||||
| 8 | |||||||||||
| 9 | # | ||||||||||
| 10 | # This file is part of MooX-ShortHas | ||||||||||
| 11 | # | ||||||||||
| 12 | # | ||||||||||
| 13 | # Christian Walde has dedicated the work to the Commons by waiving all of his | ||||||||||
| 14 | # or her rights to the work worldwide under copyright law and all related or | ||||||||||
| 15 | # neighboring legal rights he or she had in the work, to the extent allowable by | ||||||||||
| 16 | # law. | ||||||||||
| 17 | # | ||||||||||
| 18 | # Works under CC0 do not require attribution. When citing the work, you should | ||||||||||
| 19 | # not imply endorsement by the author. | ||||||||||
| 20 | # | ||||||||||
| 21 | |||||||||||
| 22 | |||||||||||
| 23 | 3 | ▶ | use Moo 2.003006 (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 24 | 3 | ▶ | use Moo::_Utils qw(_install_tracked); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 25 | |||||||||||
| 26 | 8 | ▶ | sub _modified_has { | ||||||||
|
Subroutine
_modified_has: called CC=1 SCAR=0.0
| |||||||||||
| 27 | 8 | my ( $has, $mod, $name, @args ) = @_; | |||||||||
| 28 | 8 | $has->( $name, @{$mod}, @args ); | |||||||||
| 29 | } | ||||||||||
| 30 | |||||||||||
| 31 | 4 | ▶ | sub import { | ||||||||
|
Subroutine
import: called CC=3 SCAR=11.0
| |||||||||||
| 32 | 4 | my $caller = caller; | |||||||||
| 33 | 4 | ▶ | my $has = $caller->can( "has" ) or die "Moo not loaded in caller: $caller"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | my %mods = ( | ||||||||||
| 35 | lazy => [qw( is lazy builder )], | ||||||||||
| 36 | 3 | map { $_ => [ is => $_ => required => 1 ] } qw( ro rwp rw ) | |||||||||
| 37 | ); | ||||||||||
| 38 | 3 | for my $mod ( keys %mods ) { | |||||||||
| 39 | 2 | ▶ | _install_tracked $caller => $mod => sub { | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
rwp: called CC=1 SCAR=0.0
| |||||||||||
| 40 | 2 | _modified_has $has, $mods{$mod}, @_; | |||||||||
| 41 | 12 | }; | |||||||||
| 42 | } | ||||||||||
| 43 | } | ||||||||||
| 44 | |||||||||||
| 45 | 2 | 1; | |||||||||
| 46 | |||||||||||
| 47 | __END__ | ||||||||||