| 1 | package MooseX::Role::Restricted; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | our $VERSION = '1.03'; | |||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Moose::Role; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Moose::Exporter; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Attribute::Handlers; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 1 | Moose::Exporter->setup_import_methods( | |||||||||||||||||||||||||||
| 10 | also => 'Moose::Role', | ||||||||||||||||||||||||||||
| 11 | as_is => [qw(_ATTR_CODE_Public _ATTR_CODE_Private)], | ||||||||||||||||||||||||||||
| 12 | ); | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 1 | ▶ | sub Public : ATTR(CODE) { | ||||||||||||||||||||||||||
|
Subroutine
Public: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 15 | 1 | my ($package, $symbol, $referent, $attr, $data) = @_; | |||||||||||||||||||||||||||
| 16 | 1 | (my $name = "" . *$symbol) =~ s/.*:://; | |||||||||||||||||||||||||||
| 17 | 1 | $package->meta->public_private_map->{$name} = 0; | |||||||||||||||||||||||||||
| 18 | 1 | ▶ | } | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 1 | ▶ | sub Private : ATTR(CODE) { | ||||||||||||||||||||||||||
|
Subroutine
Private: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 21 | 1 | my ($package, $symbol, $referent, $attr, $data) = @_; | |||||||||||||||||||||||||||
| 22 | 1 | (my $name = "" . *$symbol) =~ s/.*:://; | |||||||||||||||||||||||||||
| 23 | 1 | $package->meta->public_private_map->{$name} = 1; | |||||||||||||||||||||||||||
| 24 | 1 | ▶ | } | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | # fudge due to delayed resolve in A::H, needed to defined _ATTR_CODE_Private | ||||||||||||||||||||||||||||
| 27 | 1 | ▶ | sub PPP : ATTR(CODE) { } | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
PPP: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 1 | ▶ | sub init_meta { | ||||||||||||||||||||||||||
|
Subroutine
init_meta: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 30 | 1 | my ($class, %opt) = @_; | |||||||||||||||||||||||||||
| 31 | 1 | my $meta = Moose::Role->init_meta( ## | |||||||||||||||||||||||||||
| 32 | %opt, ## | ||||||||||||||||||||||||||||
| 33 | metaclass => 'MooseX::Role::Restricted::Meta' | ||||||||||||||||||||||||||||
| 34 | ); | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 1 | $meta; | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | package # hide from PAUSE | ||||||||||||||||||||||||||||
| 40 | MooseX::Role::Restricted::Meta; | ||||||||||||||||||||||||||||
| 41 | 1 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 42 | 1 | extends 'Moose::Meta::Role'; | |||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | has 'public_private_map' => ( | ||||||||||||||||||||||||||||
| 45 | is => 'rw', | ||||||||||||||||||||||||||||
| 46 | isa => 'HashRef', | ||||||||||||||||||||||||||||
| 47 | 1 | ▶ | default => sub { +{} } | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 48 | 1 | ); | |||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 1 | ▶ | sub apply { | ||||||||||||||||||||||||||
|
Subroutine
apply: called CC=6 SCAR=21.4
Pod
documented
| |||||||||||||||||||||||||||||
| 52 | 1 | my ($self, $other, %args) = @_; | |||||||||||||||||||||||||||
| 53 | 1 | my $pp_map = $self->public_private_map; | |||||||||||||||||||||||||||
| 54 | 1 | ▶ | my @exclude = grep { exists $pp_map->{$_} ? $pp_map->{$_} : /^_/; } $self->get_method_list; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 1 | ▶ | if (exists $args{excludes} && !exists $args{'-excludes'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $args{"excludes"} and not exists $args{"-excludes"}
MC/DC0%0/2
exists $args{"excludes"} and not exists $args{"-excludes"}
exists $args{"excludes"}
not exists $args{"-excludes"}
Truth table33%1/3
A and not(B)
A= exists $args{"excludes"}B= not exists $args{"-excludes"}
| |||||||||||||||||||||||||||||
| 57 | 0 | $args{'-excludes'} = delete $args{excludes}; | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 1 | ▶ | if (exists $args{'-excludes'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | push @exclude, (ref $args{'-excludes'} eq 'ARRAY') | ||||||||||||||||||||||||||||
| 62 | 0 | ? @{$args{'-excludes'}} | |||||||||||||||||||||||||||
| 63 | 0 | ▶ | : $args{'-excludes'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 1 | $args{'-excludes'} = \@exclude; | |||||||||||||||||||||||||||
| 67 | 1 | $self->SUPER::apply($other, %args); | |||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 1 | 1; | |||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | __END__ | ||||||||||||||||||||||||||||