« lib/Reaction/UI/WidgetClass/_OVER.pm
↑ Summary
lib/Reaction/InterfaceModel/Action/User/ResetPassword.pm »
| 1 | package Reaction::Role::Meta::Attribute; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 9 | ▶ | use Moose::Role; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | #is => 'Bool' ? or leave it open | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 9 | has lazy_fail => | |||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | (is => 'ro', reader => 'is_lazy_fail', required => 1, default => 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 9 | ▶ | if ( $Moose::VERSION < 1.09 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 0 | ▶ | around legal_options_for_inheritance => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 0 | return (shift->(@_), qw/valid_values/); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 1317 | ▶ | around _process_options => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=8 SCAR=21.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 1317 | my $super = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 1317 | my ($class, $name, $options) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 1317 | my $fail = $options->{lazy_fail}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 1317 | ▶ | if ( $fail ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | confess("You may not use both lazy_build and lazy_fail for one attribute") | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 115 | ▶ | if $fail && $options->{lazy_build}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$fail and $options->{"lazy_build"}
MC/DC0%0/2
$fail and $options->{"lazy_build"}
$fail
$options->{"lazy_build"}
Truth table33%1/3
A and B
A= $failB= $options->{"lazy_build"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 115 | $options->{lazy} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 115 | $options->{required} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | $options->{default} = sub { confess "${name} must be provided before calling reader" }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | #we are using this everywhere so might as well move it here. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | $options->{predicate} ||= ($name =~ /^_/) ? "_has${name}" : "has_${name}" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 1317 | ▶ | if !$options->{required} || $options->{lazy}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition83%5/6
not $options->{"required"} or $options->{"lazy"}
$options->{"predicate"} ||= $name =~ /^_/ ? "_has$name" : "has_$name"
MC/DC100%2/2
not $options->{"required"} or $options->{"lazy"}
not $options->{"required"}
$options->{"lazy"}
MC/DC0%0/2
$options->{"predicate"} ||= $name =~ /^_/ ? "_has$name" : "has_$name"
$options->{"predicate"}
$name =~ /^_/ ? "_has$name" : "has_$name"
Truth table100%3/3
not(A) or B
A= not $options->{"required"}B= $options->{"lazy"}
Truth table66%2/3
A ||= B
A= $options->{"predicate"}B= $name =~ /^_/ ? "_has$name" : "has_$name"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 1317 | $super->($class, $name, $options); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 9 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 9 | foreach my $type (qw(clearer predicate)) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 18 | my $value_meth = do { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 18 | ▶ | if ($type eq 'clearer') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 9 | 'clear_value' | |||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | } elsif ($type eq 'predicate') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 9 | 'has_value' | |||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | confess "NOTREACHED"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | __PACKAGE__->meta->add_method("get_${type}_method" => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_clearer_method: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | my $info = $self->$type; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | return $info unless ref $info; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | my ($name) = %$info; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | return $name; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 18 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | __PACKAGE__->meta->add_method("get_${type}_method_ref" => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_clearer_method_ref: not called CC=3 SCAR=20.5
Subroutine
__ANON__: called CC=3 SCAR=20.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | if ((my $name = $self->${\"get_${type}_method"}) && $self->associated_class) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/6
my $name = $self->${\("get_${type}_method");} and $self->associated_class
my $name = $self->${\("get_${type}_method");} and $self->associated_class
MC/DC0%0/2
my $name = $self->${\("get_${type}_method");} and $self->associated_class
my $name = $self->${\("get_${type}_method");}
$self->associated_class
MC/DC0%0/2
my $name = $self->${\("get_${type}_method");} and $self->associated_class
my $name = $self->${\("get_${type}_method");}
$self->associated_class
Truth table0%0/3
A and B
A= my $name = $self->${\("get_${type}_method");}B= $self->associated_class
Truth table0%0/3
A and B
A= my $name = $self->${\("get_${type}_method");}B= $self->associated_class
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | return $self->associated_class->get_method($name); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | return sub { $self->$value_meth(@_); } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 18 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 9 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | __END__; | ||||||||||||||||||||||||||||||||||||||||||||||||||