| 1 | package Moose::Meta::TypeConstraint::Registry; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 398 | our $VERSION = '2.4001'; | |||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||
| 4 | 398 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 398 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 398 | ▶ | use metaclass; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 398 | ▶ | use Scalar::Util 'blessed'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 398 | ▶ | use parent 'Class::MOP::Object'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 398 | ▶ | use Moose::Util 'throw_exception'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 398 | __PACKAGE__->meta->add_attribute('parent_registry' => ( | |||||||||||||||||||||||||||||||||||||||||
| 15 | reader => 'get_parent_registry', | ||||||||||||||||||||||||||||||||||||||||||
| 16 | writer => 'set_parent_registry', | ||||||||||||||||||||||||||||||||||||||||||
| 17 | predicate => 'has_parent_registry', | ||||||||||||||||||||||||||||||||||||||||||
| 18 | Class::MOP::_definition_context(), | ||||||||||||||||||||||||||||||||||||||||||
| 19 | )); | ||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | __PACKAGE__->meta->add_attribute('type_constraints' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 22 | reader => 'type_constraints', | ||||||||||||||||||||||||||||||||||||||||||
| 23 | 399 | ▶ | default => sub { {} }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 398 | Class::MOP::_definition_context(), | |||||||||||||||||||||||||||||||||||||||||
| 25 | )); | ||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 399 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 399 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 29 | 399 | my $self = $class->_new(@_); | |||||||||||||||||||||||||||||||||||||||||
| 30 | 399 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 18243 | ▶ | sub has_type_constraint { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_type_constraint: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 18243 | my ($self, $type_name) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 35 | 18243 | ▶ | ($type_name and exists $self->type_constraints->{$type_name}) ? 1 : 0 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$type_name and exists $self->type_constraints->{$type_name}
MC/DC100%2/2
$type_name and exists $self->type_constraints->{$type_name}
$type_name
exists $self->type_constraints->{$type_name}
Truth table100%3/3
A and B
A= $type_nameB= exists $self->type_constraints->{$type_name}
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | 26643 | ▶ | sub get_type_constraint { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_type_constraint: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 26643 | my ($self, $type_name) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 40 | 26643 | ▶ | return unless defined $type_name; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | 26643 | $self->type_constraints->{$type_name} | |||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | 11736 | ▶ | sub add_type_constraint { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_type_constraint: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | 11736 | my ($self, $type) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | 11736 | ▶ | unless ( $type && blessed $type && $type->isa('Moose::Meta::TypeConstraint') ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$type and builtin::blessed($type) and $type->isa("Moose::Meta::TypeConstraint")
$type and builtin::blessed($type)
MC/DC100%3/3
$type and builtin::blessed($type) and $type->isa("Moose::Meta::TypeConstraint")
$type
builtin::blessed($type)
$type->isa("Moose::Meta::TypeConstraint")
Truth table100%4/4
A and B and C
A= $typeB= builtin::blessed($type)C= $type->isa("Moose::Meta::TypeConstraint")
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | 4 | throw_exception( InvalidTypeConstraint => registry_object => $self, | |||||||||||||||||||||||||||||||||||||||||
| 49 | type => $type | ||||||||||||||||||||||||||||||||||||||||||
| 50 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 11732 | $self->type_constraints->{$type->name} = $type; | |||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | sub find_type_constraint { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_type_constraint: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | my ($self, $type_name) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | return $self->get_type_constraint($type_name) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | if $self->has_type_constraint($type_name); | ||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | return $self->get_parent_registry->find_type_constraint($type_name) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | if $self->has_parent_registry; | ||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | 398 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | # ABSTRACT: registry for type constraints | ||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | __END__ | ||||||||||||||||||||||||||||||||||||||||||