« lib/Reaction/InterfaceModel/Reflector/DBIC.pm
↑ Summary
lib/Reaction/InterfaceModel/Action/DBIC/ResultSet/Create.pm »
| 1 | package Reaction::InterfaceModel::Reflector::SearchSpec; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use Moose::Exporter; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use Carp qw(confess); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use Reaction::Types::Core qw(SimpleStr NonEmptySimpleStr); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | #use aliased 'T365::BrokerInterface::SearchSpec'; | ||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use aliased 'Moose::Meta::TypeConstraint::Enum'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 0 | ▶ | sub reflect_attributes_from_target { | ||||||||||||||||||||||||||
|
Subroutine
reflect_attributes_from_target: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 10 | 0 | my ($caller, $foreign) = @_; | |||||||||||||||||||||||||||
| 11 | 0 | ▶ | confess 'Class name to reflect search specification is required as first argument to reflect_attributes_from_target' | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 12 | unless $foreign; | ||||||||||||||||||||||||||||
| 13 | # $foreign ||= SearchSpec; | ||||||||||||||||||||||||||||
| 14 | 0 | my $meta = Class::MOP::Class->initialize($caller); | |||||||||||||||||||||||||||
| 15 | 0 | my %info; | |||||||||||||||||||||||||||
| 16 | 0 | foreach my $attr ( | |||||||||||||||||||||||||||
| 17 | 0 | grep { $_->name !~ /^_/ } | |||||||||||||||||||||||||||
| 18 | $foreign->meta->get_all_attributes | ||||||||||||||||||||||||||||
| 19 | ) { | ||||||||||||||||||||||||||||
| 20 | #warn "Doing ".$attr->name; | ||||||||||||||||||||||||||||
| 21 | 0 | my %args; | |||||||||||||||||||||||||||
| 22 | 0 | { my @copy = qw(required is isa); | |||||||||||||||||||||||||||
| 23 | 0 | @args{@copy} = @{$attr}{@copy}; | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | 0 | ▶ | if ($args{isa} eq NonEmptySimpleStr) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | #warn "here ".$attr->name." ".join(', ', %args); | ||||||||||||||||||||||||||||
| 27 | 0 | ▶ | if ($args{required}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 28 | 0 | confess "I really have no idea how we got here"; | |||||||||||||||||||||||||||
| 29 | } else { | ||||||||||||||||||||||||||||
| 30 | 0 | $args{isa} = SimpleStr; | |||||||||||||||||||||||||||
| 31 | 0 | $args{required} = 1; | |||||||||||||||||||||||||||
| 32 | 0 | ▶ | push(@{$info{empty}||=[]}, $attr->name); | ||||||||||||||||||||||||||
|
Condition0%0/2
$info{"empty"} ||= []
MC/DC0%0/1
$info{"empty"} ||= []
$info{"empty"}
Truth table0%0/2
A
A= $info{"empty"}
| |||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | } else { | ||||||||||||||||||||||||||||
| 35 | 0 | ▶ | push(@{$info{normal}||=[]}, $attr->name); | ||||||||||||||||||||||||||
|
Condition0%0/2
$info{"normal"} ||= []
MC/DC0%0/1
$info{"normal"} ||= []
$info{"normal"}
Truth table0%0/2
A
A= $info{"normal"}
| |||||||||||||||||||||||||||||
| 36 | #warn "here instead ".$attr->name; | ||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | 0 | my $tc; | |||||||||||||||||||||||||||
| 39 | 0 | ▶ | if (($tc = $args{type_constraint}) && ($tc->isa(Enum))) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$tc = $args{"type_constraint"} and $tc->isa("Moose::Meta::TypeConstraint::Enum")
MC/DC0%0/2
$tc = $args{"type_constraint"} and $tc->isa("Moose::Meta::TypeConstraint::Enum")
$tc = $args{"type_constraint"}
$tc->isa("Moose::Meta::TypeConstraint::Enum")
Truth table0%0/3
A and B
A= $tc = $args{"type_constraint"}B= $tc->isa("Moose::Meta::TypeConstraint::Enum")
| |||||||||||||||||||||||||||||
| 40 | 0 | $args{valid_values} = $tc->values; | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | 0 | $args{predicate} = "has_".$attr->name; | |||||||||||||||||||||||||||
| 43 | 0 | $meta->add_attribute($attr->name => \%args); | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | 0 | \%info; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 4 | Moose::Exporter->setup_import_methods( | |||||||||||||||||||||||||||
| 49 | with_caller => [ 'reflect_attributes_from_target' ] | ||||||||||||||||||||||||||||
| 50 | ); | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 4 | 1; | |||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||