« lib/Reaction/UI/ViewPort/SearchableListViewContainer.pm
↑ Summary
lib/Reaction/InterfaceModel/Reflector/SearchSpec.pm »
| 1 | package Reaction::InterfaceModel::Reflector::DBIC; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use aliased 'Reaction::InterfaceModel::Action::DBIC::ResultSet::Create'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 5 | ▶ | use aliased 'Reaction::InterfaceModel::Action::DBIC::ResultSet::DeleteAll'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 5 | ▶ | use aliased 'Reaction::InterfaceModel::Action::DBIC::Result::Update'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 5 | ▶ | use aliased 'Reaction::InterfaceModel::Action::DBIC::Result::Delete'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 5 | ▶ | use aliased 'Reaction::InterfaceModel::Collection::Virtual::ResultSet'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 5 | ▶ | use aliased 'Reaction::InterfaceModel::Object'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 5 | ▶ | use aliased 'Reaction::InterfaceModel::Action'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 5 | ▶ | use Reaction::Class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 5 | ▶ | use Class::MOP; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 5 | ▶ | use Catalyst::Utils; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 5 | ▶ | use namespace::clean -except => [ qw(meta) ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 6 | ▶ | has make_classes_immutable => (isa => "Bool", is => "rw", required => 1, default => sub{ 1 }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | #user defined actions and prototypes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 5 | has object_actions => (isa => "HashRef", is => "rw", lazy_build => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 5 | has collection_actions => (isa => "HashRef", is => "rw", lazy_build => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | #which actions to create by default | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 5 | has default_object_actions => (isa => "ArrayRef", is => "rw", lazy_build => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 5 | has default_collection_actions => (isa => "ArrayRef", is => "rw", lazy_build => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | #builtin actions and prototypes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 5 | has builtin_object_actions => (isa => "HashRef", is => "rw", lazy_build => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 5 | has builtin_collection_actions => (isa => "HashRef", is => "rw", lazy_build => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 5 | ▶ | sub _build_object_actions { {} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_object_actions: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 5 | ▶ | sub _build_collection_actions { {} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_collection_actions: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 5 | ▶ | sub _build_default_object_actions { [ qw/Update Delete/ ] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_default_object_actions: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 5 | ▶ | sub _build_default_collection_actions { [ qw/Create DeleteAll/ ] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_default_collection_actions: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 5 | ▶ | sub _build_builtin_object_actions { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_builtin_object_actions: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 5 | Update => { name => 'Update', base => Update }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | Delete => { name => 'Delete', base => Delete, attributes => [] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 5 | ▶ | sub _build_builtin_collection_actions { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_builtin_collection_actions: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 5 | Create => {name => 'Create', base => Create }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | DeleteAll => {name => 'DeleteAll', base => DeleteAll, attributes => [] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 15 | ▶ | sub _all_object_actions { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_all_object_actions: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 15 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 15 | return $self->merge_hashes | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | ($self->builtin_object_actions, $self->object_actions); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 15 | ▶ | sub _all_collection_actions { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_all_collection_actions: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 15 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 15 | return $self->merge_hashes | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | ($self->builtin_collection_actions, $self->collection_actions); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 5 | ▶ | sub dm_name_from_class_name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dm_name_from_class_name: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 5 | my($self, $class) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 5 | ▶ | confess("wrong arguments") unless $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 5 | $class =~ s/::/_/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 5 | $class = "_" . $self->_class_to_attribute_name($class) . "_store"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 5 | return $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 18 | ▶ | sub dm_name_from_source_name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dm_name_from_source_name: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 18 | my($self, $source) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 18 | ▶ | confess("wrong arguments") unless $source; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 18 | $source =~ s/([a-z0-9])([A-Z])/${1}_${2}/g ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 18 | $source = "_" . $self->_class_to_attribute_name($source) . "_store"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 18 | return $source; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 36 | ▶ | sub class_name_from_source_name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
class_name_from_source_name: called CC=3 SCAR=12.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 36 | my ($self, $model_class, $source_name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 36 | ▶ | confess("wrong arguments") unless $model_class && $source_name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$model_class and $source_name
MC/DC0%0/2
$model_class and $source_name
$model_class
$source_name
Truth table33%1/3
A and B
A= $model_classB= $source_name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 36 | return join "::", $model_class, $source_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 31 | ▶ | sub class_name_for_collection_of { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
class_name_for_collection_of: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 31 | my ($self, $object_class) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 31 | ▶ | confess("wrong arguments") unless $object_class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 31 | return "${object_class}::Collection"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 120 | ▶ | sub merge_hashes { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
merge_hashes: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 120 | my($self, $left, $right) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 120 | return Catalyst::Utils::merge_hashes($left, $right); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 110 | ▶ | sub parse_reflect_rules { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_reflect_rules: called CC=12 SCAR=28.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 110 | my ($self, $rules, $haystack) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 110 | ▶ | confess('$rules must be an array reference') unless ref $rules eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 110 | ▶ | confess('$haystack must be an array reference') unless ref $haystack eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 110 | my $needles = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 110 | my (@exclude, @include, $global_opts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 110 | ▶ | if(@$rules == 2 && $rules->[0] eq '-exclude'){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@$rules == 2 and $rules->[0] eq "-exclude"
MC/DC0%0/2
@$rules == 2 and $rules->[0] eq "-exclude"
@$rules == 2
$rules->[0] eq "-exclude"
Truth table66%2/3
A and B
A= @$rules == 2B= $rules->[0] eq "-exclude"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | push(@exclude, (ref $rules->[1] eq 'ARRAY' ? @{$rules->[1]} : $rules->[1])); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 110 | for my $rule ( @$rules ){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 124 | ▶ | if (ref $rule eq 'ARRAY' && $rule->[0] eq '-exclude'){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
ref $rule eq "ARRAY" and $rule->[0] eq "-exclude"
MC/DC100%2/2
ref $rule eq "ARRAY" and $rule->[0] eq "-exclude"
ref $rule eq "ARRAY"
$rule->[0] eq "-exclude"
Truth table100%3/3
A and B
A= ref $rule eq "ARRAY"B= $rule->[0] eq "-exclude"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | push(@exclude, (ref $rule->[1] eq 'ARRAY' ? @{$rule->[1]} : $rule->[1])); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | } elsif( ref $rule eq 'HASH' ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | $global_opts = ref $global_opts eq 'HASH' ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | $self->merge_hashes($global_opts, $rule) : $rule; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 120 | push(@include, $rule); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 414 | ▶ | my $check_exclude = sub{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 414 | for my $rule (@exclude){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 16 | ▶ | return 1 if(ref $rule eq 'Regexp' ? $_[0] =~ /$rule/ : $_[0] eq $rule); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 410 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 110 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 110 | @$haystack = grep { !$check_exclude->($_) } @$haystack; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 110 | $self->merge_reflect_rules(\@include, $needles, $haystack, $global_opts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 110 | return $needles; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 114 | ▶ | sub merge_reflect_rules { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
merge_reflect_rules: called CC=12 SCAR=26.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 114 | my ($self, $rules, $needles, $haystack, $local_opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 114 | for my $rule ( @$rules ){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 124 | ▶ | if(!ref $rule && ( grep {$rule eq $_} @$haystack ) ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition66%2/3
not ref $rule and grep {$rule eq $_;} @$haystack
MC/DC50%1/2
not ref $rule and grep {$rule eq $_;} @$haystack
not ref $rule
grep {$rule eq $_;} @$haystack
Truth table66%2/3
not(A) and B
A= not ref $ruleB= grep {$rule eq $_;} @$haystack
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | $needles->{$rule} = defined $needles->{$rule} ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 75 | ▶ | $self->merge_hashes($needles->{$rule}, $local_opts) : $local_opts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } elsif( ref $rule eq 'Regexp' ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 45 | for my $match ( grep { /$rule/ } @$haystack ){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | $needles->{$match} = defined $needles->{$match} ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 198 | ▶ | $self->merge_hashes($needles->{$match}, $local_opts) : $local_opts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | } elsif( ref $rule eq 'ARRAY' ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 4 | my $opts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 4 | ▶ | $opts = pop(@$rule) if @$rule > 1 and ref $rule->[$#$rule] eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@$rule > 1 and ref $$rule[$rule->$#*] eq "HASH"
MC/DC0%0/2
@$rule > 1 and ref $$rule[$rule->$#*] eq "HASH"
@$rule > 1
ref $$rule[$rule->$#*] eq "HASH"
Truth table33%1/3
A and B
A= @$rule > 1B= ref $$rule[$rule->$#*] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 4 | ▶ | $opts = $self->merge_hashes($local_opts, $opts) if defined $local_opts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 4 | $self->merge_reflect_rules($rule, $needles, $haystack, $opts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 5 | ▶ | sub reflect_schema { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reflect_schema: called CC=21 SCAR=36.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 5 | my ($self, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 5 | ▶ | my $base = delete $opts{base} || Object; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $opts{'base'} || 'Reaction::InterfaceModel::Object'
MC/DC0%0/1
delete $opts{'base'} || 'Reaction::InterfaceModel::Object'
delete $opts{'base'}
Truth table50%1/2
A
A= delete $opts{'base'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 5 | ▶ | my $roles = delete $opts{roles} || []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $opts{'roles'} || []
MC/DC0%0/1
delete $opts{'roles'} || []
delete $opts{'roles'}
Truth table50%1/2
A
A= delete $opts{'roles'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 5 | my $model = delete $opts{model_class}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 5 | my $schema = delete $opts{schema_class}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 5 | my $dm_name = delete $opts{domain_model_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 5 | ▶ | my $dm_args = delete $opts{domain_model_args} || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $opts{'domain_model_args'} || {}
MC/DC0%0/1
delete $opts{'domain_model_args'} || {}
delete $opts{'domain_model_args'}
Truth table50%1/2
A
A= delete $opts{'domain_model_args'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 5 | ▶ | $dm_name ||= $self->dm_name_from_class_name($schema); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$dm_name ||= $self->dm_name_from_class_name($schema)
MC/DC0%0/2
$dm_name ||= $self->dm_name_from_class_name($schema)
$dm_name
$self->dm_name_from_class_name($schema)
Truth table33%1/3
A ||= B
A= $dm_nameB= $self->dm_name_from_class_name($schema)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | #load all necessary classes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 5 | ▶ | confess("model_class and schema_class are required parameters") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$model and $schema
MC/DC0%0/2
$model and $schema
$model
$schema
Truth table33%1/3
A and B
A= $modelB= $schema
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | unless($model && $schema); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 5 | Class::MOP::load_class( $base ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 5 | Class::MOP::load_class( $schema ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 5 | ▶ | my $meta = $self->_load_or_create( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | $model, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | superclasses => [$base], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | ( @$roles ? (roles => $roles) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | # sources => undef, #default to qr/./ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | # sources => [], #default to nothing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | # sources => qr//, #DWIM, treated as [qr//] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | # sources => [{...}] #DWIM, treat as [qr/./, {...} ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | # sources => [[-exclude => ...]] #DWIM, treat as [qr/./, [-exclude => ...]] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 5 | my $haystack = [ $schema->sources ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 5 | my $rules = delete $opts{sources}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 5 | ▶ | if(!defined $rules){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | $rules = [qr/./]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | } elsif( ref $rules eq 'Regexp'){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | $rules = [ $rules ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | ▶ | } elsif( ref $rules eq 'ARRAY' && @$rules){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $rules eq "ARRAY" and @$rules
MC/DC0%0/2
ref $rules eq "ARRAY" and @$rules
ref $rules eq "ARRAY"
@$rules
Truth table33%1/3
A and B
A= ref $rules eq "ARRAY"B= @$rules
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | #don't add a qr/./ rule if we have at least one match rule | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 5 | ▶ | push(@$rules, qr/./) unless grep {(ref $_ eq 'ARRAY' && $_->[0] ne '-exclude') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition55%5/9
ref $_ eq 'ARRAY' && $_->[0] ne '-exclude' || !ref($_) || ref $_ eq 'Regexp'
ref $_ eq "ARRAY" and $_->[0] ne "-exclude" or not ref $_
ref $_ eq "ARRAY" and $_->[0] ne "-exclude"
MC/DC0%0/4
ref $_ eq 'ARRAY' && $_->[0] ne '-exclude' || !ref($_) || ref $_ eq 'Regexp'
ref $_ eq "ARRAY"
$_->[0] ne "-exclude"
not ref $_
ref $_ eq 'Regexp'
Truth table28%2/7
A and B or not(C) || D
A= ref $_ eq "ARRAY"B= $_->[0] ne "-exclude"C= not ref $_D= ref $_ eq 'Regexp'
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | || !ref $_ || ref $_ eq 'Regexp'} @$rules; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 5 | my $sources = $self->parse_reflect_rules($rules, $haystack); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 5 | ▶ | my $make_immutable = $meta->is_immutable || $self->make_classes_immutable; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$meta->is_immutable || $self->make_classes_immutable
MC/DC0%0/2
$meta->is_immutable || $self->make_classes_immutable
$meta->is_immutable
$self->make_classes_immutable
Truth table33%1/3
A || B
A= $meta->is_immutableB= $self->make_classes_immutable
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 5 | ▶ | $meta->make_mutable if $meta->is_immutable; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 5 | $meta->add_domain_model | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | ($dm_name, is => 'rw', isa => $schema, required => 1, %$dm_args); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 5 | for my $source_name (keys %$sources){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 15 | ▶ | my $source_opts = $sources->{$source_name} || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$sources->{$source_name} || {}
MC/DC100%1/1
$sources->{$source_name} || {}
$sources->{$source_name}
Truth table100%2/2
A
A= $sources->{$source_name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 15 | $self->reflect_source( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | source_name => $source_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | parent_class => $model, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | schema_class => $schema, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | source_class => $schema->class($source_name), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | parent_domain_model_name => $dm_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | %$source_opts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 5 | ▶ | $meta->make_immutable if $make_immutable; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 5 | return $meta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 30 | ▶ | sub _compute_source_options { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_compute_source_options: called CC=22 SCAR=55.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 30 | my ($self, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 30 | my $schema = delete $opts{schema_class}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 30 | my $source_name = delete $opts{source_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 30 | my $source_class = delete $opts{source_class}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 30 | my $parent = delete $opts{parent_class}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 30 | my $parent_dm = delete $opts{parent_domain_model_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | #this is the part where I hate my life for promissing all sorts of DWIMery | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 30 | ▶ | confess("parent_class and source_name or source_class are required parameters") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$parent and $source_name || $source_class
$source_name or $source_class
MC/DC0%0/3
$parent and $source_name || $source_class
$parent
$source_name
$source_class
Truth table25%1/4
A and B or C
A= $parentB= $source_nameC= $source_class
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | unless($parent && ($source_name || $source_class)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 30 | ▶ | OUTER: until( $schema && $source_name && $source_class && $parent_dm ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
$schema and $source_name and $source_class and $parent_dm
$schema and $source_name and $source_class
$schema and $source_name
MC/DC0%0/4
$schema and $source_name and $source_class and $parent_dm
$schema
$source_name
$source_class
$parent_dm
Truth table20%1/5
A and B and C and D
A= $schemaB= $source_nameC= $source_classD= $parent_dm
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | if( $schema && !$source_name){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$schema and not $source_name
MC/DC0%0/2
$schema and not $source_name
$schema
not $source_name
Truth table0%0/3
A and not(B)
A= $schemaB= not $source_name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | next OUTER if $source_name = $schema->source($source_class)->source_name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | ▶ | } elsif( $schema && !$source_class){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$schema and not $source_class
MC/DC0%0/2
$schema and not $source_class
$schema
not $source_class
Truth table0%0/3
A and not(B)
A= $schemaB= not $source_class
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | next OUTER if $source_class = eval { $schema->class($source_name) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | ▶ | my @haystack = $parent_dm ? $parent->meta->find_attribute_by_name($parent_dm) : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | #there's a lot of guessing going on, but it should work fine on most cases | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | INNER: for my $needle (@haystack){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | my $isa = $needle->_isa_metadata; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | ▶ | next INNER unless Class::MOP::load_class( $isa->_isa_metadata ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | next INNER unless $isa->isa('DBIx::Class::Schema'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | if( $source_name ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | my $src_class = eval{ $isa->class($source_name) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | next INNER unless $src_class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | ▶ | next INNER if($source_class && $source_class ne $src_class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$source_class and $source_class ne $src_class
MC/DC0%0/2
$source_class and $source_class ne $src_class
$source_class
$source_class ne $src_class
Truth table0%0/3
A and B
A= $source_classB= $source_class ne $src_class
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | $schema = $isa; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | $parent_dm = $needle->name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | $source_class = $src_class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | next OUTER; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | confess("Could not determine options automatically from: schema " . | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | "'${schema}', source_name '${source_name}', source_class " . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | "'${source_class}', parent_domain_model_name '${parent_dm}'"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 30 | source_name => $source_name, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | schema_class => $schema, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | source_class => $source_class, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | parent_class => $parent, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | parent_domain_model_name => $parent_dm, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 53 | ▶ | sub _class_to_attribute_name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_class_to_attribute_name: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 53 | my ( $self, $str ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 53 | ▶ | confess("wrong arguments passed for _class_to_attribute_name") unless $str; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 53 | return join('_', map lc, split(/::|(?<=[a-z0-9])(?=[A-Z])/, $str)) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 15 | ▶ | sub add_source { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_source: called CC=12 SCAR=33.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 15 | my ($self, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 15 | my $model = delete $opts{model_class}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 15 | my $reader = delete $opts{reader}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 15 | my $source = delete $opts{source_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 15 | my $dm_name = delete $opts{domain_model_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 15 | my $collection = delete $opts{collection_class}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 15 | ▶ | my $name = delete $opts{attribute_name} || $source; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
delete $opts{'attribute_name'} || $source
MC/DC0%0/2
delete $opts{'attribute_name'} || $source
delete $opts{'attribute_name'}
$source
Truth table33%1/3
A || B
A= delete $opts{'attribute_name'}B= $source
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 15 | ▶ | confess("model_class and source_name are required parameters") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$model and $source
MC/DC0%0/2
$model and $source
$model
$source
Truth table33%1/3
A and B
A= $modelB= $source
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | unless $model && $source; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 15 | my $meta = $model->meta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 15 | ▶ | unless( $collection ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | my $object = $self->class_name_from_source_name($model, $source); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | $collection = $self->class_name_for_collection_of($object); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 15 | ▶ | unless( $reader ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 15 | $reader = $source; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 15 | $reader =~ s/([a-z0-9])([A-Z])/${1}_${2}/g ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 15 | $reader = $self->_class_to_attribute_name($reader) . "_collection"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 15 | ▶ | unless( $dm_name ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | my @haystack = $meta->domain_models; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | ▶ | if( @haystack > 1 ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | @haystack = grep { $_->_isa_metadata->isa('DBIx::Class::Schema') } @haystack; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | if(@haystack == 1){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | $dm_name = $haystack[0]->name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | } elsif(@haystack > 1){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | confess("Failed to automatically determine domain_model_name. More than one " . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | "possible match (".(join ", ", map{"'".$_->name."'"} @haystack).")"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | confess("Failed to automatically determine domain_model_name. No matches."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | my %attr_opts = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | required => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | isa => $collection, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | reader => $reader, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | predicate => "has_" . $self->_class_to_attribute_name($name) , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | domain_model => $dm_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | orig_attr_name => $source, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 6 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 6 | $collection->new | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | _source_resultset => $_[0]->$dm_name->resultset($source), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | _parent => $_[0], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 15 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 15 | my $make_immutable = $meta->is_immutable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 15 | ▶ | $meta->make_mutable if $make_immutable; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 15 | my $attr = $meta->add_attribute($name, %attr_opts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 15 | ▶ | $meta->make_immutable if $make_immutable; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 15 | return $attr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 15 | ▶ | sub reflect_source { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reflect_source: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 15 | my ($self, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 15 | ▶ | my $collection = delete $opts{collection} || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $opts{'collection'} || {}
MC/DC0%0/1
delete $opts{'collection'} || {}
delete $opts{'collection'}
Truth table50%1/2
A
A= delete $opts{'collection'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 15 | %opts = %{ $self->merge_hashes(\%opts, $self->_compute_source_options(%opts)) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 15 | my $obj_meta = $self->reflect_source_object(%opts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | my $col_meta = $self->reflect_source_collection | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | object_class => $obj_meta->name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | source_class => $opts{source_class}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | schema => $opts{schema_class}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 15 | %$collection | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | $self->add_source( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | %opts, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | model_class => delete $opts{parent_class}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | domain_model_name => delete $opts{parent_domain_model_name}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 15 | collection_class => $col_meta->name, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 15 | ▶ | sub reflect_source_collection { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reflect_source_collection: called CC=24 SCAR=43.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 15 | my ($self, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 15 | ▶ | my $base = delete $opts{base} || ResultSet; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $opts{'base'} || 'Reaction::InterfaceModel::Collection::Virtual::ResultSet'
MC/DC0%0/1
delete $opts{'base'} || 'Reaction::InterfaceModel::Collection::Virtual::ResultSet'
delete $opts{'base'}
Truth table50%1/2
A
A= delete $opts{'base'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 15 | ▶ | my $roles = delete $opts{roles} || []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $opts{'roles'} || []
MC/DC0%0/1
delete $opts{'roles'} || []
delete $opts{'roles'}
Truth table50%1/2
A
A= delete $opts{'roles'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 15 | my $class = delete $opts{class}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 15 | my $object = delete $opts{object_class}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 15 | my $source = delete $opts{source_class}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 15 | my $action_rules = delete $opts{actions}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 15 | my $schema = delete $opts{schema}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 15 | ▶ | confess('object_class and source_class are required parameters') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$object and $source
MC/DC0%0/2
$object and $source
$object
$source
Truth table33%1/3
A and B
A= $objectB= $source
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | unless $object && $source; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 15 | ▶ | $class ||= $self->class_name_for_collection_of($object); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$class ||= $self->class_name_for_collection_of($object)
MC/DC0%0/2
$class ||= $self->class_name_for_collection_of($object)
$class
$self->class_name_for_collection_of($object)
Truth table33%1/3
A ||= B
A= $classB= $self->class_name_for_collection_of($object)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 15 | Class::MOP::load_class( $base ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 15 | Class::MOP::load_class( $object ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 15 | ▶ | my $meta = $self->_load_or_create( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | $class, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | superclasses => [$base], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | ( @$roles ? (roles => $roles) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 15 | ▶ | my $make_immutable = $meta->is_immutable || $self->make_classes_immutable;; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$meta->is_immutable || $self->make_classes_immutable
MC/DC0%0/2
$meta->is_immutable || $self->make_classes_immutable
$meta->is_immutable
$self->make_classes_immutable
Truth table33%1/3
A || B
A= $meta->is_immutableB= $self->make_classes_immutable
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 15 | ▶ | $meta->make_mutable if $meta->is_immutable; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | ▶ | $meta->add_method(_build_member_type => sub{ $object } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_member_type: called CC=1 SCAR=0.4
Subroutine
__ANON__: not called CC=1 SCAR=0.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | #XXX as a default pass the domain model as a target_model until i come up with something | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | #better through the coercion method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 6 | ▶ | my $def_act_args = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 6 | my $super = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 6 | return { (target_model => $_[0]->_source_resultset), %{ $super->(@_) } }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 15 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 15 | $meta->add_around_method_modifier('_default_action_args_for', $def_act_args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 15 | my $all_actions = $self->_all_collection_actions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 15 | my $action_haystack = [keys %$all_actions]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 15 | ▶ | if(!defined $action_rules){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 15 | $action_rules = $self->default_collection_actions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | ▶ | } elsif( (!ref $action_rules && $action_rules) || (ref $action_rules eq 'Regexp') ){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
not ref $action_rules and $action_rules or ref $action_rules eq "Regexp"
not ref $action_rules and $action_rules
MC/DC0%0/3
not ref $action_rules and $action_rules or ref $action_rules eq "Regexp"
not ref $action_rules
$action_rules
ref $action_rules eq "Regexp"
Truth table0%0/5
not(A) and B or C
A= not ref $action_rulesB= $action_rulesC= ref $action_rules eq "Regexp"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | $action_rules = [ $action_rules ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | ▶ | } elsif( ref $action_rules eq 'ARRAY' && @$action_rules){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $action_rules eq "ARRAY" and @$action_rules
MC/DC0%0/2
ref $action_rules eq "ARRAY" and @$action_rules
ref $action_rules eq "ARRAY"
@$action_rules
Truth table0%0/3
A and B
A= ref $action_rules eq "ARRAY"B= @$action_rules
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | #don't add a qr/./ rule if we have at least one match rule | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | push(@$action_rules, qr/./) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | ▶ | unless grep {(ref $_ eq 'ARRAY' && $_->[0] ne '-exclude') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
ref $_ eq 'ARRAY' && $_->[0] ne '-exclude' || !ref($_) || ref $_ eq 'Regexp'
ref $_ eq "ARRAY" and $_->[0] ne "-exclude" or not ref $_
ref $_ eq "ARRAY" and $_->[0] ne "-exclude"
MC/DC0%0/4
ref $_ eq 'ARRAY' && $_->[0] ne '-exclude' || !ref($_) || ref $_ eq 'Regexp'
ref $_ eq "ARRAY"
$_->[0] ne "-exclude"
not ref $_
ref $_ eq 'Regexp'
Truth table0%0/7
A and B or not(C) || D
A= ref $_ eq "ARRAY"B= $_->[0] ne "-exclude"C= not ref $_D= ref $_ eq 'Regexp'
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | || !ref $_ || ref $_ eq 'Regexp'} @$action_rules; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | # XXX this is kind of a dirty hack to support custom actions that are not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | # previously defined and still be able to use the parse_reflect_rules mechanism | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | my @custom_actions = grep {!exists $all_actions->{$_}} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | ▶ | map{ $_->[0] } grep {ref $_ eq 'ARRAY' && $_->[0] ne '-exclude'} @$action_rules; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $_ eq 'ARRAY' && $_->[0] ne '-exclude'
MC/DC0%0/2
ref $_ eq 'ARRAY' && $_->[0] ne '-exclude'
ref $_ eq 'ARRAY'
$_->[0] ne '-exclude'
Truth table33%1/3
A && B
A= ref $_ eq 'ARRAY'B= $_->[0] ne '-exclude'
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 15 | push(@$action_haystack, @custom_actions); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 15 | my $actions = $self->parse_reflect_rules($action_rules, $action_haystack); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 15 | for my $action (keys %$actions){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | my $action_opts = $self->merge_hashes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 30 | ▶ | ($all_actions->{$action} || {}, $actions->{$action} || {}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%2/4
$all_actions->{$action} || {}
$actions->{$action} || {}
MC/DC0%0/1
$all_actions->{$action} || {}
$all_actions->{$action}
MC/DC0%0/1
$actions->{$action} || {}
$actions->{$action}
Truth table50%1/2
A
A= $all_actions->{$action}
Truth table50%1/2
A
A= $actions->{$action}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | #NOTE: If the name of the action is not specified in the prototype then use it's | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | #hash key as the name. I think this is sane beahvior, but I've actually been thinking | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | #of making Action prototypes their own separate objects | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 30 | $self->reflect_source_action( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | schema => $schema, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | name => $action, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | object_class => $object, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | source_class => $source, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | %$action_opts, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | # XXX i will move this to use the coercion method soon. this will be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | # GoodEnough until then. I still need to think a little about the type coercion | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | # thing so i don't make a mess of it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 12 | ▶ | my $act_args = sub { #override target model for this action | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 12 | my $super = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 12 | ▶ | return { %{ $super->(@_) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | ($_[1] eq $action ? (target_model => $_[0]->_source_resultset) : () ) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 30 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 30 | $meta->add_around_method_modifier('_default_action_args_for', $act_args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 15 | ▶ | $meta->make_immutable if $make_immutable; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 15 | return $meta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 15 | ▶ | sub reflect_source_object { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reflect_source_object: called CC=44 SCAR=51.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 15 | my($self, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 15 | %opts = %{ $self->merge_hashes(\%opts, $self->_compute_source_options(%opts)) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 15 | ▶ | my $base = delete $opts{base} || Object; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $opts{'base'} || 'Reaction::InterfaceModel::Object'
MC/DC0%0/1
delete $opts{'base'} || 'Reaction::InterfaceModel::Object'
delete $opts{'base'}
Truth table50%1/2
A
A= delete $opts{'base'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 15 | ▶ | my $roles = delete $opts{roles} || []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $opts{'roles'} || []
MC/DC0%0/1
delete $opts{'roles'} || []
delete $opts{'roles'}
Truth table50%1/2
A
A= delete $opts{'roles'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 15 | my $class = delete $opts{class}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 15 | my $dm_name = delete $opts{domain_model_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 15 | ▶ | my $dm_opts = delete $opts{domain_model_args} || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $opts{'domain_model_args'} || {}
MC/DC0%0/1
delete $opts{'domain_model_args'} || {}
delete $opts{'domain_model_args'}
Truth table50%1/2
A
A= delete $opts{'domain_model_args'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 15 | my $source_name = delete $opts{source_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 15 | my $schema = delete $opts{schema_class}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 15 | my $source_class = delete $opts{source_class}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 15 | my $parent = delete $opts{parent_class}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 15 | my $parent_dm = delete $opts{parent_domain_model_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 15 | my $action_rules = delete $opts{actions}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 15 | my $attr_rules = delete $opts{attributes}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 15 | ▶ | $class ||= $self->class_name_from_source_name($parent, $source_name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$class ||= $self->class_name_from_source_name($parent, $source_name)
MC/DC0%0/2
$class ||= $self->class_name_from_source_name($parent, $source_name)
$class
$self->class_name_from_source_name($parent, $source_name)
Truth table33%1/3
A ||= B
A= $classB= $self->class_name_from_source_name($parent, $source_name)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 15 | Class::MOP::load_class($parent); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 15 | ▶ | Class::MOP::load_class($schema) if $schema; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 15 | Class::MOP::load_class($source_class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 15 | ▶ | my $meta = $self->_load_or_create( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | $class, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | superclasses => [$base], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | ( @$roles ? (roles => $roles) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | #create the domain model | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 15 | ▶ | $dm_name ||= $self->dm_name_from_source_name($source_name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$dm_name ||= $self->dm_name_from_source_name($source_name)
MC/DC0%0/2
$dm_name ||= $self->dm_name_from_source_name($source_name)
$dm_name
$self->dm_name_from_source_name($source_name)
Truth table33%1/3
A ||= B
A= $dm_nameB= $self->dm_name_from_source_name($source_name)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 15 | $dm_opts->{isa} = $source_class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 15 | ▶ | $dm_opts->{is} ||= 'rw'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$dm_opts->{"is"} ||= "rw"
MC/DC0%0/1
$dm_opts->{"is"} ||= "rw"
$dm_opts->{"is"}
Truth table50%1/2
A
A= $dm_opts->{"is"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 15 | ▶ | $dm_opts->{required} ||= 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$dm_opts->{"required"} ||= 1
MC/DC0%0/1
$dm_opts->{"required"} ||= 1
$dm_opts->{"required"}
Truth table50%1/2
A
A= $dm_opts->{"required"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 15 | ▶ | my $make_immutable = $meta->is_immutable || $self->make_classes_immutable;; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$meta->is_immutable || $self->make_classes_immutable
MC/DC0%0/2
$meta->is_immutable || $self->make_classes_immutable
$meta->is_immutable
$self->make_classes_immutable
Truth table66%2/3
A || B
A= $meta->is_immutableB= $self->make_classes_immutable
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 15 | ▶ | $meta->make_mutable if $meta->is_immutable; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 15 | my $dm_attr = $meta->add_domain_model($dm_name, %$dm_opts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 15 | my $dm_reader = $dm_attr->get_read_method; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 15 | ▶ | unless( $class->can('inflate_result') ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 111 | ▶ | my $inflate_method = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
inflate_result: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 111 | my $class = shift; my ($src) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 111 | ▶ | $src = $src->resolve if $src->isa('DBIx::Class::ResultSourceHandle'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 111 | $class->new($dm_name, $src->result_class->inflate_result(@_)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 15 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 15 | $meta->add_method('inflate_result', $inflate_method); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | #XXX this is here to allow action prototypes to work with ListView | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | # maybe Collections hsould have this kind of thing too to allow you to reconstruct them? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | #i like the possibility to be honest... as aset of key/value pairs they could be URId | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | #XXX move to using 'handles' for this? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | ▶ | $meta->add_method('__id', sub {shift->$dm_reader->id} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__id: not called CC=1 SCAR=6.9
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 15 | ▶ | unless $class->can('__id'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | #XXX this one is for Action, ChooseOne and ChooseMany need this shit | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | ▶ | $meta->add_method('__ident_condition', sub {shift->$dm_reader->ident_condition} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ident_condition: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 15 | ▶ | unless $class->can('__ident_condition'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | #XXX this is just a disaster | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | ▶ | $meta->add_method('display_name', sub {shift->$dm_reader->display_name} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
display_name: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 15 | ▶ | if( $source_class->can('display_name') && !$class->can('display_name')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$source_class->can("display_name") and not $class->can("display_name")
MC/DC0%0/2
$source_class->can("display_name") and not $class->can("display_name")
$source_class->can("display_name")
not $class->can("display_name")
Truth table33%1/3
A and not(B)
A= $source_class->can("display_name")B= not $class->can("display_name")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | #XXX as a default pass the domain model as a target_model until i come up with something | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | #better through the coercion method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 9 | ▶ | my $def_act_args = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 9 | my $super = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 9 | ▶ | confess "no dm reader: $dm_reader on $_[0]" unless $_[0]->can($dm_reader); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 9 | return { (target_model => $_[0]->$dm_reader), %{ $super->(@_) } }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 15 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 15 | $meta->add_around_method_modifier('_default_action_args_for', $def_act_args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | # attributes => undef, #default to qr/./ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | # attributes => [], #default to nothing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | # attributes => qr//, #DWIM, treated as [qr//] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | # attributes => [{...}] #DWIM, treat as [qr/./, {...} ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | # attributes => [[-exclude => ...]] #DWIM, treat as [qr/./, [-exclude => ...]] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | my $attr_haystack = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 15 | [ map { $_->name } $source_class->meta->get_all_attributes ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 15 | ▶ | if(!defined $attr_rules){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 11 | $attr_rules = [qr/./]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | ▶ | } elsif( (!ref $attr_rules && $attr_rules) || (ref $attr_rules eq 'Regexp') ){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
not ref $attr_rules and $attr_rules or ref $attr_rules eq "Regexp"
not ref $attr_rules and $attr_rules
MC/DC0%0/3
not ref $attr_rules and $attr_rules or ref $attr_rules eq "Regexp"
not ref $attr_rules
$attr_rules
ref $attr_rules eq "Regexp"
Truth table20%1/5
not(A) and B or C
A= not ref $attr_rulesB= $attr_rulesC= ref $attr_rules eq "Regexp"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | $attr_rules = [ $attr_rules ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | ▶ | } elsif( ref $attr_rules eq 'ARRAY' && @$attr_rules){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $attr_rules eq "ARRAY" and @$attr_rules
MC/DC0%0/2
ref $attr_rules eq "ARRAY" and @$attr_rules
ref $attr_rules eq "ARRAY"
@$attr_rules
Truth table33%1/3
A and B
A= ref $attr_rules eq "ARRAY"B= @$attr_rules
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | #don't add a qr/./ rule if we have at least one match rule | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | push(@$attr_rules, qr/./) unless | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 4 | ▶ | grep {(ref $_ eq 'ARRAY' && $_->[0] ne '-exclude') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
ref $_ eq 'ARRAY' && $_->[0] ne '-exclude' || !ref($_) || ref $_ eq 'Regexp'
ref $_ eq "ARRAY" and $_->[0] ne "-exclude" or not ref $_
ref $_ eq "ARRAY" and $_->[0] ne "-exclude"
MC/DC0%0/4
ref $_ eq 'ARRAY' && $_->[0] ne '-exclude' || !ref($_) || ref $_ eq 'Regexp'
ref $_ eq "ARRAY"
$_->[0] ne "-exclude"
not ref $_
ref $_ eq 'Regexp'
Truth table14%1/7
A and B or not(C) || D
A= ref $_ eq "ARRAY"B= $_->[0] ne "-exclude"C= not ref $_D= ref $_ eq 'Regexp'
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | || !ref $_ || ref $_ eq 'Regexp'} @$attr_rules; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 15 | my $attributes = $self->parse_reflect_rules($attr_rules, $attr_haystack); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 15 | for my $attr_name (keys %$attributes){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | $self->reflect_source_object_attribute( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | schema => $schema, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | class => $class, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | source_class => $source_class, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | parent_class => $parent, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | attribute_name => $attr_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | domain_model_name => $dm_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 66 | ▶ | %{ $attributes->{$attr_name} || {}}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$attributes->{$attr_name} || {}
MC/DC0%0/1
$attributes->{$attr_name} || {}
$attributes->{$attr_name}
Truth table50%1/2
A
A= $attributes->{$attr_name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 15 | my $all_actions = $self->_all_object_actions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 15 | my $action_haystack = [keys %$all_actions]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 15 | ▶ | if(!defined $action_rules){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 15 | $action_rules = $self->default_object_actions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | ▶ | } elsif( (!ref $action_rules && $action_rules) || (ref $action_rules eq 'Regexp') ){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
not ref $action_rules and $action_rules or ref $action_rules eq "Regexp"
not ref $action_rules and $action_rules
MC/DC0%0/3
not ref $action_rules and $action_rules or ref $action_rules eq "Regexp"
not ref $action_rules
$action_rules
ref $action_rules eq "Regexp"
Truth table0%0/5
not(A) and B or C
A= not ref $action_rulesB= $action_rulesC= ref $action_rules eq "Regexp"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | $action_rules = [ $action_rules ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | ▶ | } elsif( ref $action_rules eq 'ARRAY' && @$action_rules){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $action_rules eq "ARRAY" and @$action_rules
MC/DC0%0/2
ref $action_rules eq "ARRAY" and @$action_rules
ref $action_rules eq "ARRAY"
@$action_rules
Truth table0%0/3
A and B
A= ref $action_rules eq "ARRAY"B= @$action_rules
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | #don't add a qr/./ rule if we have at least one match rule | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | push(@$action_rules, qr/./) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | ▶ | unless grep {(ref $_ eq 'ARRAY' && $_->[0] ne '-exclude') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
ref $_ eq 'ARRAY' && $_->[0] ne '-exclude' || !ref($_) || ref $_ eq 'Regexp'
ref $_ eq "ARRAY" and $_->[0] ne "-exclude" or not ref $_
ref $_ eq "ARRAY" and $_->[0] ne "-exclude"
MC/DC0%0/4
ref $_ eq 'ARRAY' && $_->[0] ne '-exclude' || !ref($_) || ref $_ eq 'Regexp'
ref $_ eq "ARRAY"
$_->[0] ne "-exclude"
not ref $_
ref $_ eq 'Regexp'
Truth table0%0/7
A and B or not(C) || D
A= ref $_ eq "ARRAY"B= $_->[0] ne "-exclude"C= not ref $_D= ref $_ eq 'Regexp'
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | || !ref $_ || ref $_ eq 'Regexp'} @$action_rules; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | # XXX this is kind of a dirty hack to support custom actions that are not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | # previously defined and still be able to use the parse_reflect_rules mechanism | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | my @custom_actions = grep {!exists $all_actions->{$_}} map{ $_->[0] } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 15 | ▶ | grep {ref $_ eq 'ARRAY' && $_->[0] ne '-exclude'} @$action_rules; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $_ eq 'ARRAY' && $_->[0] ne '-exclude'
MC/DC0%0/2
ref $_ eq 'ARRAY' && $_->[0] ne '-exclude'
ref $_ eq 'ARRAY'
$_->[0] ne '-exclude'
Truth table33%1/3
A && B
A= ref $_ eq 'ARRAY'B= $_->[0] ne '-exclude'
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 15 | push(@$action_haystack, @custom_actions); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 15 | my $actions = $self->parse_reflect_rules($action_rules, $action_haystack); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 15 | for my $action (keys %$actions){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | my $action_opts = $self->merge_hashes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 30 | ▶ | ($all_actions->{$action} || {}, $actions->{$action} || {}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%2/4
$all_actions->{$action} || {}
$actions->{$action} || {}
MC/DC0%0/1
$all_actions->{$action} || {}
$all_actions->{$action}
MC/DC0%0/1
$actions->{$action} || {}
$actions->{$action}
Truth table50%1/2
A
A= $all_actions->{$action}
Truth table50%1/2
A
A= $actions->{$action}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | #NOTE: If the name of the action is not specified in the prototype then use it's | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | #hash key as the name. I think this is sane beahvior, but I've actually been thinking | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | #of making Action prototypes their own separate objects | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 30 | $self->reflect_source_action( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | schema => $schema, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | name => $action, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | object_class => $class, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | source_class => $source_class, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | %$action_opts, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | # XXX i will move this to use the coercion method soon. this will be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | # GoodEnough until then. I still need to think a little about the type coercion | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | # thing so i don't make a mess of it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 18 | ▶ | my $act_args = sub { #override target model for this action | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 18 | my $super = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 18 | ▶ | confess "no dm reader: $dm_reader on $_[0]" unless $_[0]->can($dm_reader); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 18 | ▶ | return { %{ $super->(@_) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | ($_[1] eq $action ? (target_model => $_[0]->$dm_reader) : () ) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 30 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 30 | $meta->add_around_method_modifier('_default_action_args_for', $act_args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 15 | ▶ | $meta->make_immutable if $make_immutable; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 15 | return $meta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | # needs class, attribute_name domain_model_name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 66 | ▶ | sub reflect_source_object_attribute { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reflect_source_object_attribute: called CC=8 SCAR=25.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 66 | my ($self, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 66 | ▶ | unless( $opts{attribute_name} && $opts{class} && $opts{parent_class} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%4/12
$opts{"attribute_name"} and $opts{"class"} and $opts{"parent_class"} and $opts{"source_class"} || $opts{"domain_model_name"}
$opts{"attribute_name"} and $opts{"class"} and $opts{"parent_class"}
$opts{"attribute_name"} and $opts{"class"}
$opts{"source_class"} or $opts{"domain_model_name"}
MC/DC0%0/5
$opts{"attribute_name"} and $opts{"class"} and $opts{"parent_class"} and $opts{"source_class"} || $opts{"domain_model_name"}
$opts{"attribute_name"}
$opts{"class"}
$opts{"parent_class"}
$opts{"source_class"}
$opts{"domain_model_name"}
Truth table16%1/6
A and B and C and D or E
A= $opts{"attribute_name"}B= $opts{"class"}C= $opts{"parent_class"}D= $opts{"source_class"}E= $opts{"domain_model_name"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | && ( $opts{source_class} || $opts{domain_model_name} ) ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 0 | confess( "Error: class, parent_class, attribute_name, and either " . | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | "domain_model_name or source_class are required parameters" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 66 | my $meta = $opts{class}->meta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 66 | my $attr_opts = $self->parameters_for_source_object_attribute(%opts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 66 | my $make_immutable = $meta->is_immutable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 66 | ▶ | $meta->make_mutable if $meta->is_immutable; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 66 | my $attr = $meta->add_attribute($opts{attribute_name}, %$attr_opts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 66 | ▶ | $meta->make_immutable if $make_immutable; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 66 | return $attr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | # needs class, attribute_name domain_model_name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 66 | ▶ | sub parameters_for_source_object_attribute { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parameters_for_source_object_attribute: called CC=21 SCAR=31.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 66 | my ($self, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 66 | my $class = delete $opts{class}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 66 | my $attr_name = delete $opts{attribute_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 66 | my $dm_name = delete $opts{domain_model_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 66 | my $source_class = delete $opts{source_class}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 66 | my $parent_class = delete $opts{parent_class}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 66 | my $schema = $opts{schema}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 66 | ▶ | confess("parent_class is a required argument") unless $parent_class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 66 | ▶ | confess("You must supply at least one of domain_model_name and source_class") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$dm_name or $source_class
MC/DC0%0/2
$dm_name or $source_class
$dm_name
$source_class
Truth table33%1/3
A or B
A= $dm_nameB= $source_class
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | unless $dm_name || $source_class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 66 | my $source = $schema->source($source_class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 66 | my $from_attr = $source_class->meta->find_attribute_by_name($attr_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 66 | my $reader = $from_attr->get_read_method; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 66 | ▶ | die("Could not find reader for attribute '$attr_name' on $source_class") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | unless $reader; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | #default options. lazy build but no outsider method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | my %attr_opts = ( is => 'ro', lazy => 1, required => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | clearer => "_clear_${attr_name}", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | predicate => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | "has_${attr_name}" => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 0 | ▶ | sub { defined(shift->$dm_name->$reader) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_foo_list: not called CC=1 SCAR=6.9
Subroutine
has_description: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 66 | domain_model => $dm_name, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | orig_attr_name => $attr_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 66 | ▶ | $attr_opts{coerce} = 1 if $from_attr->should_coerce; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | #m2m / has_many | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 66 | my $m2m_meta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 66 | ▶ | if(my $coderef = $source->result_class->can('_m2m_metadata')){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 25 | $m2m_meta = $source->result_class->$coderef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 66 | ▶ | my $constraint_is_ArrayRef = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$from_attr->type_constraint->name eq 'ArrayRef' || $from_attr->type_constraint->is_subtype_of('ArrayRef')
MC/DC50%1/2
$from_attr->type_constraint->name eq 'ArrayRef' || $from_attr->type_constraint->is_subtype_of('ArrayRef')
$from_attr->type_constraint->name eq 'ArrayRef'
$from_attr->type_constraint->is_subtype_of('ArrayRef')
Truth table66%2/3
A || B
A= $from_attr->type_constraint->name eq 'ArrayRef'B= $from_attr->type_constraint->is_subtype_of('ArrayRef')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | $from_attr->type_constraint->name eq 'ArrayRef' || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | $from_attr->type_constraint->is_subtype_of('ArrayRef'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 66 | ▶ | if( my $rel_info = $source->relationship_info($attr_name) ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 10 | my $rel_accessor = $rel_info->{attrs}->{accessor}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 10 | my $rel_moniker = $schema->source($rel_info->{class})->source_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 10 | ▶ | if($rel_accessor eq 'multi' && $constraint_is_ArrayRef) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$rel_accessor eq "multi" and $constraint_is_ArrayRef
MC/DC50%1/2
$rel_accessor eq "multi" and $constraint_is_ArrayRef
$rel_accessor eq "multi"
$constraint_is_ArrayRef
Truth table66%2/3
A and B
A= $rel_accessor eq "multi"B= $constraint_is_ArrayRef
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | #has_many | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 5 | my $sm = $self->class_name_from_source_name($parent_class, $rel_moniker); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | #type constraint is a collection, and default builds it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 5 | my $isa = $attr_opts{isa} = $self->class_name_for_collection_of($sm); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 5 | $attr_opts{default} = eval "sub { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | my \$rs = shift->${dm_name}->related_resultset('${attr_name}'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | return ${isa}->new(_source_resultset => \$rs); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | }"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | ▶ | } elsif( $rel_accessor eq 'single' || $rel_accessor eq 'filter' ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$rel_accessor eq "single" or $rel_accessor eq "filter"
MC/DC0%0/2
$rel_accessor eq "single" or $rel_accessor eq "filter"
$rel_accessor eq "single"
$rel_accessor eq "filter"
Truth table33%1/3
A or B
A= $rel_accessor eq "single"B= $rel_accessor eq "filter"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | #belongs_to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | #type constraint is the foreign IM object, default inflates it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 5 | my $isa = $attr_opts{isa} = $self->class_name_from_source_name($parent_class, $rel_moniker); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 5 | $attr_opts{default} = eval "sub { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | if (defined(my \$o = shift->${dm_name}->${reader})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | return ${isa}->inflate_result(\$o->result_source, { \$o->get_columns }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | }"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | ▶ | } elsif( $constraint_is_ArrayRef && $attr_name =~ m/^(.*)_list$/ ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$constraint_is_ArrayRef and $attr_name =~ /^(.*)_list$/
MC/DC100%2/2
$constraint_is_ArrayRef and $attr_name =~ /^(.*)_list$/
$constraint_is_ArrayRef
$attr_name =~ /^(.*)_list$/
Truth table100%3/3
A and B
A= $constraint_is_ArrayRefB= $attr_name =~ /^(.*)_list$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | #m2m magic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 5 | my $mm_name = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 5 | my $link_table = "links_to_${mm_name}_list"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 5 | my ($hm_source, $far_side); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 5 | ▶ | eval { $hm_source = $source->related_source($link_table); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | || confess "Can't find ${link_table} has_many for ${mm_name}_list"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 5 | ▶ | eval { $far_side = $hm_source->related_source($mm_name); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | || confess "Can't find ${mm_name} belongs_to on ".$hm_source->result_class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | ." traversing many-many for ${mm_name}_list"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 5 | my $sm = $self->class_name_from_source_name($parent_class,$far_side->source_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 5 | my $isa = $attr_opts{isa} = $self->class_name_for_collection_of($sm); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | #proper collections will remove the result_class uglyness. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 5 | $attr_opts{default} = eval "sub { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | my \$rs = shift->${dm_name}->related_resultset('${link_table}')->related_resultset('${mm_name}'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | return ${isa}->new(_source_resultset => \$rs); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | }"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | ▶ | } elsif( $constraint_is_ArrayRef && defined $m2m_meta && exists $m2m_meta->{$attr_name} ){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%4/6
$constraint_is_ArrayRef and defined $m2m_meta and exists $m2m_meta->{$attr_name}
$constraint_is_ArrayRef and defined $m2m_meta
MC/DC33%1/3
$constraint_is_ArrayRef and defined $m2m_meta and exists $m2m_meta->{$attr_name}
$constraint_is_ArrayRef
defined $m2m_meta
exists $m2m_meta->{$attr_name}
Truth table50%2/4
A and B and C
A= $constraint_is_ArrayRefB= defined $m2m_metaC= exists $m2m_meta->{$attr_name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | #m2m if using introspectable m2m component | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 5 | my $rel = $m2m_meta->{$attr_name}->{relation}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 5 | my $far_rel = $m2m_meta->{$attr_name}->{foreign_relation}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 5 | my $far_source = $source->related_source($rel)->related_source($far_rel); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 5 | my $sm = $self->class_name_from_source_name($parent_class, $far_source->source_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 5 | my $isa = $attr_opts{isa} = $self->class_name_for_collection_of($sm); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 5 | my $rs_meth = $m2m_meta->{$attr_name}->{rs_method}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 5 | $attr_opts{default} = eval "sub { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | return ${isa}->new(_source_resultset => shift->${dm_name}->${rs_meth}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | }"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | #no rel | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 46 | $attr_opts{isa} = $from_attr->_isa_metadata; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 46 | my $default_code = "sub{ shift->${dm_name}->${reader} }"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 46 | $attr_opts{default} = eval $default_code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 46 | ▶ | die "Could not generate default for attribute, code '$default_code' did not compile with: $@" if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 66 | return \%attr_opts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 60 | ▶ | sub reflect_source_action { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reflect_source_action: called CC=27 SCAR=43.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 60 | my($self, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 60 | my $name = delete $opts{name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 60 | ▶ | my $base = delete $opts{base} || Action; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $opts{'base'} || 'Reaction::InterfaceModel::Action'
MC/DC0%0/1
delete $opts{'base'} || 'Reaction::InterfaceModel::Action'
delete $opts{'base'}
Truth table50%1/2
A
A= delete $opts{'base'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 60 | ▶ | my $roles = delete $opts{roles} || []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $opts{'roles'} || []
MC/DC0%0/1
delete $opts{'roles'} || []
delete $opts{'roles'}
Truth table50%1/2
A
A= delete $opts{'roles'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | 60 | my $class = delete $opts{class}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 60 | my $object = delete $opts{object_class}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 60 | my $source = delete $opts{source_class}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 60 | my $schema = delete $opts{schema}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 60 | ▶ | confess("name, object_class and source_class are required arguments") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$source and $name and $object
$source and $name
MC/DC0%0/3
$source and $name and $object
$source
$name
$object
Truth table25%1/4
A and B and C
A= $sourceB= $nameC= $object
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | unless $source && $name && $object; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 60 | my $attr_rules = delete $opts{attributes}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 60 | ▶ | $class ||= $object->_default_action_class_for($name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$class ||= $object->_default_action_class_for($name)
MC/DC0%0/2
$class ||= $object->_default_action_class_for($name)
$class
$object->_default_action_class_for($name)
Truth table33%1/3
A ||= B
A= $classB= $object->_default_action_class_for($name)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 60 | Class::MOP::load_class( $base ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 60 | Class::MOP::load_class( $object ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 60 | Class::MOP::load_class( $source ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | #print STDERR "\n\t", ref $attr_rules eq 'ARRAY' ? @$attr_rules : $attr_rules,"\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | # attributes => undef, #default to qr/./ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | # attributes => [], #default to nothing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | # attributes => qr//, #DWIM, treated as [qr//] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | # attributes => [{...}] #DWIM, treat as [qr/./, {...} ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | # attributes => [[-exclude => ...]] #DWIM, treat as [qr/./, [-exclude => ...]] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 60 | my $attr_haystack = [ map { $_->name } $object->parameter_attributes ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 60 | ▶ | if(!defined $attr_rules){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | 30 | $attr_rules = [qr/./]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | ▶ | } elsif( (!ref $attr_rules && $attr_rules) || (ref $attr_rules eq 'Regexp') ){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
not ref $attr_rules and $attr_rules or ref $attr_rules eq "Regexp"
not ref $attr_rules and $attr_rules
MC/DC0%0/3
not ref $attr_rules and $attr_rules or ref $attr_rules eq "Regexp"
not ref $attr_rules
$attr_rules
ref $attr_rules eq "Regexp"
Truth table20%1/5
not(A) and B or C
A= not ref $attr_rulesB= $attr_rulesC= ref $attr_rules eq "Regexp"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 0 | $attr_rules = [ $attr_rules ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | ▶ | } elsif( ref $attr_rules eq 'ARRAY' && @$attr_rules){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $attr_rules eq "ARRAY" and @$attr_rules
MC/DC0%0/2
ref $attr_rules eq "ARRAY" and @$attr_rules
ref $attr_rules eq "ARRAY"
@$attr_rules
Truth table33%1/3
A and B
A= ref $attr_rules eq "ARRAY"B= @$attr_rules
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | #don't add a qr/./ rule if we have at least one match rule | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | push(@$attr_rules, qr/./) unless | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 0 | ▶ | grep {(ref $_ eq 'ARRAY' && $_->[0] ne '-exclude') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
ref $_ eq 'ARRAY' && $_->[0] ne '-exclude' || !ref($_) || ref $_ eq 'Regexp'
ref $_ eq "ARRAY" and $_->[0] ne "-exclude" or not ref $_
ref $_ eq "ARRAY" and $_->[0] ne "-exclude"
MC/DC0%0/4
ref $_ eq 'ARRAY' && $_->[0] ne '-exclude' || !ref($_) || ref $_ eq 'Regexp'
ref $_ eq "ARRAY"
$_->[0] ne "-exclude"
not ref $_
ref $_ eq 'Regexp'
Truth table0%0/7
A and B or not(C) || D
A= ref $_ eq "ARRAY"B= $_->[0] ne "-exclude"C= not ref $_D= ref $_ eq 'Regexp'
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | || !ref $_ || ref $_ eq 'Regexp'} @$attr_rules; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | #print STDERR "${name}\t${class}\t${base}\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | #print STDERR "\t${object}\t${source}\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | #print STDERR "\t",@$attr_rules,"\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 60 | my $o_meta = $object->meta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | 60 | my $s_meta = $source->meta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 60 | my $attributes = $self->parse_reflect_rules($attr_rules, $attr_haystack); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | #create the class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 60 | ▶ | my $meta = $self->_load_or_create( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | $class, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | superclasses => [$base], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | ( @$roles ? (roles => $roles) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 60 | ▶ | my $make_immutable = $meta->is_immutable || $self->make_classes_immutable; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$meta->is_immutable || $self->make_classes_immutable
MC/DC0%0/2
$meta->is_immutable || $self->make_classes_immutable
$meta->is_immutable
$self->make_classes_immutable
Truth table33%1/3
A || B
A= $meta->is_immutableB= $self->make_classes_immutable
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 60 | ▶ | $meta->make_mutable if $meta->is_immutable; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 60 | for my $attr_name (keys %$attributes){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 132 | ▶ | my $attr_opts = $attributes->{$attr_name} || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$attributes->{$attr_name} || {}
MC/DC0%0/1
$attributes->{$attr_name} || {}
$attributes->{$attr_name}
Truth table50%1/2
A
A= $attributes->{$attr_name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | 132 | my $o_attr = $o_meta->find_attribute_by_name($attr_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 132 | ▶ | my $s_attr_name = $o_attr->orig_attr_name || $attr_name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$o_attr->orig_attr_name || $attr_name
MC/DC0%0/2
$o_attr->orig_attr_name || $attr_name
$o_attr->orig_attr_name
$attr_name
Truth table33%1/3
A || B
A= $o_attr->orig_attr_nameB= $attr_name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 132 | my $s_attr = $s_meta->find_attribute_by_name($s_attr_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 132 | ▶ | confess("Unable to find attribute for '${s_attr_name}' via '${source}'") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | unless defined $s_attr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 132 | ▶ | next unless $s_attr->get_write_method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$s_attr->get_write_method and not $s_attr->get_write_method =~ /^_/
MC/DC50%1/2
$s_attr->get_write_method and not $s_attr->get_write_method =~ /^_/
$s_attr->get_write_method
not $s_attr->get_write_method =~ /^_/
Truth table66%2/3
A and not(B)
A= $s_attr->get_write_methodB= not $s_attr->get_write_method =~ /^_/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | && $s_attr->get_write_method !~ /^_/; #only rw attributes! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 102 | my $attr_params = $self->parameters_for_source_object_action_attribute | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | schema => $schema, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | object_class => $object, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | source_class => $source, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | attribute_name => $attr_name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 102 | $meta->add_attribute( $attr_name => %$attr_params); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 60 | ▶ | $meta->make_immutable if $make_immutable; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 60 | return $meta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 102 | ▶ | sub parameters_for_source_object_action_attribute { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parameters_for_source_object_action_attribute: called CC=20 SCAR=33.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 102 | my ($self, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 102 | my $object = delete $opts{object_class}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 102 | my $attr_name = delete $opts{attribute_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | 102 | my $source_class = delete $opts{source_class}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 102 | my $schema = delete $opts{schema}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | 102 | my $source = $schema->source($source_class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 102 | ▶ | confess("object_class and attribute_name are required parameters") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$attr_name and $object
MC/DC0%0/2
$attr_name and $object
$attr_name
$object
Truth table33%1/3
A and B
A= $attr_nameB= $object
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | unless $attr_name && $object; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 102 | my $o_meta = $object->meta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | 102 | my $dm_name = $o_meta->find_attribute_by_name($attr_name)->domain_model; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | 102 | ▶ | $source_class ||= $o_meta->find_attribute_by_name($dm_name)->_isa_metadata; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$source_class ||= $o_meta->find_attribute_by_name($dm_name)->_isa_metadata
MC/DC0%0/2
$source_class ||= $o_meta->find_attribute_by_name($dm_name)->_isa_metadata
$source_class
$o_meta->find_attribute_by_name($dm_name)->_isa_metadata
Truth table33%1/3
A ||= B
A= $source_classB= $o_meta->find_attribute_by_name($dm_name)->_isa_metadata
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | 102 | my $from_attr = $source_class->meta->find_attribute_by_name($attr_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | #print STDERR "$attr_name is type: " . $from_attr->meta->name . "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 102 | ▶ | confess("${attr_name} is not writeable and can not be reflected") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | unless $from_attr->get_write_method; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 102 | ▶ | my %attr_opts = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | isa => $from_attr->_isa_metadata, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | required => $from_attr->is_required, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | ($from_attr->is_required | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | ? () : (clearer => "clear_${attr_name}")), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | predicate => "has_${attr_name}", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | 102 | ▶ | if ($attr_opts{required}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | 70 | ▶ | if($from_attr->has_default) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | 0 | $attr_opts{lazy} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 0 | $attr_opts{default} = $from_attr->default; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | 70 | $attr_opts{lazy_fail} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | 102 | my $m2m_meta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | 102 | ▶ | if(my $coderef = $source_class->result_class->can('_m2m_metadata')){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | 30 | $m2m_meta = $source_class->result_class->$coderef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | #test for relationships | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | 102 | ▶ | my $constraint_is_ArrayRef = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$from_attr->type_constraint->name eq 'ArrayRef' || $from_attr->type_constraint->is_subtype_of('ArrayRef')
MC/DC50%1/2
$from_attr->type_constraint->name eq 'ArrayRef' || $from_attr->type_constraint->is_subtype_of('ArrayRef')
$from_attr->type_constraint->name eq 'ArrayRef'
$from_attr->type_constraint->is_subtype_of('ArrayRef')
Truth table66%2/3
A || B
A= $from_attr->type_constraint->name eq 'ArrayRef'B= $from_attr->type_constraint->is_subtype_of('ArrayRef')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | $from_attr->type_constraint->name eq 'ArrayRef' || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | $from_attr->type_constraint->is_subtype_of('ArrayRef'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 102 | ▶ | if (my $rel_info = $source->relationship_info($attr_name)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 10 | my $rel_accessor = $rel_info->{attrs}->{accessor}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 10 | ▶ | if($rel_accessor eq 'multi' && $constraint_is_ArrayRef) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$rel_accessor eq "multi" and $constraint_is_ArrayRef
MC/DC0%0/2
$rel_accessor eq "multi" and $constraint_is_ArrayRef
$rel_accessor eq "multi"
$constraint_is_ArrayRef
Truth table33%1/3
A and B
A= $rel_accessor eq "multi"B= $constraint_is_ArrayRef
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | 0 | confess "${attr_name} is a rw has_many, this won't work."; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | ▶ | } elsif( $rel_accessor eq 'single' || $rel_accessor eq 'filter') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$rel_accessor eq "single" or $rel_accessor eq "filter"
MC/DC0%0/2
$rel_accessor eq "single" or $rel_accessor eq "filter"
$rel_accessor eq "single"
$rel_accessor eq "filter"
Truth table33%1/3
A or B
A= $rel_accessor eq "single"B= $rel_accessor eq "filter"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | 0 | ▶ | $attr_opts{valid_values} = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | 0 | shift->target_model->result_source->related_source($attr_name)->resultset; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | 10 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | ▶ | } elsif ( $constraint_is_ArrayRef && $attr_name =~ m/^(.*)_list$/) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$constraint_is_ArrayRef and $attr_name =~ /^(.*)_list$/
MC/DC100%2/2
$constraint_is_ArrayRef and $attr_name =~ /^(.*)_list$/
$constraint_is_ArrayRef
$attr_name =~ /^(.*)_list$/
Truth table100%3/3
A and B
A= $constraint_is_ArrayRefB= $attr_name =~ /^(.*)_list$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | 10 | my $mm_name = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 10 | my $link_table = "links_to_${mm_name}_list"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 0 | ▶ | $attr_opts{default} = sub { [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | 9 | ▶ | $attr_opts{valid_values} = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 9 | shift->target_model->result_source->related_source($link_table) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | ->related_source($mm_name)->resultset; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | 10 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | ▶ | } elsif( $constraint_is_ArrayRef && defined $m2m_meta && exists $m2m_meta->{$attr_name} ){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%4/6
$constraint_is_ArrayRef and defined $m2m_meta and exists $m2m_meta->{$attr_name}
$constraint_is_ArrayRef and defined $m2m_meta
MC/DC33%1/3
$constraint_is_ArrayRef and defined $m2m_meta and exists $m2m_meta->{$attr_name}
$constraint_is_ArrayRef
defined $m2m_meta
exists $m2m_meta->{$attr_name}
Truth table50%2/4
A and B and C
A= $constraint_is_ArrayRefB= defined $m2m_metaC= exists $m2m_meta->{$attr_name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | #m2m if using introspectable m2m component | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | 10 | my $rel = $m2m_meta->{$attr_name}->{relation}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | 10 | my $far_rel = $m2m_meta->{$attr_name}->{foreign_relation}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | 0 | ▶ | $attr_opts{default} = sub { [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | 0 | ▶ | $attr_opts{valid_values} = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | 0 | shift->target_model->result_source->related_source($rel) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | ->related_source($far_rel)->resultset; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 10 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | #use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | #print STDERR "\n" .$attr_name ." - ". $object . "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | #print STDERR Dumper(\%attr_opts); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | 102 | return \%attr_opts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | 95 | ▶ | sub _load_or_create { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_load_or_create: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | 95 | my ($self, $class, %options) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | 95 | ▶ | if( $self->_maybe_load_class($class) ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | 8 | return $class->meta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | 87 | my $base; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 87 | ▶ | if( exists $options{superclasses} ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | 87 | ($base) = @{ $options{superclasses} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | 0 | $base = 'Reaction::InterfaceModel::Action'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | 87 | return $base->meta->create($class, %options); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | 95 | ▶ | sub _maybe_load_class { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_maybe_load_class: called CC=3 SCAR=11.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 95 | my ($self, $class) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | 95 | my $file = $class . '.pm'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | 95 | $file =~ s{::}{/}g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | 95 | my $ret = eval { Class::MOP::load_class($class) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | 95 | ▶ | if ($INC{$file} && $@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$INC{$file} and $@
MC/DC0%0/2
$INC{$file} and $@
$INC{$file}
$@
Truth table66%2/3
A and B
A= $INC{$file}B= $@
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | 0 | confess "Error loading ${class}: $@"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | 95 | return $ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | 5 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | #--------#---------#---------#---------#---------#---------#---------#---------# | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | __END__; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||