| 1 | package Context::Set::Restriction; | ||||||||||||||||||||
| 2 | 4 | ▶ | use Moose; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | |||||||||||||||||||||
| 4 | 4 | extends qw/Context::Set/; | |||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 4 | has '+name' => ( required => 1 ); | |||||||||||||||||||
| 7 | 4 | has 'restricted' => ( is => 'ro' , isa => 'Context::Set' , required => 1 , weak_ref => 1 ); | |||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | =head1 NAME | ||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | Context::Set::Restriction - A restriction of a Context. | ||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | =head2 SYNOPSYS | ||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | $general->has_property('a'); # General has 'a' | ||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | my $restriction = $general->restrict('specialized'); | ||||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | $restriction->has_property('a'); # The restriction inherits from the properties of general. | ||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | $restriction->set_property('b', 'value'); | ||||||||||||||||||||
| 22 | $restriction->has_property('b'); # ONLY the restriction has property b. | ||||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | =cut | ||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | =head2 fullname | ||||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | See superclass. | ||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | =cut | ||||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | 413 | ▶ | sub fullname{ | ||||||||||||||||||
|
Subroutine
fullname: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 34 | 413 | my ($self) = @_; | |||||||||||||||||||
| 35 | 413 | return $self->restricted()->fullname().'/'.$self->name(); | |||||||||||||||||||
| 36 | } | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | =head2 is_inside | ||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | See superclass | ||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | =cut | ||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | 34 | ▶ | sub is_inside{ | ||||||||||||||||||
|
Subroutine
is_inside: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||
| 45 | 34 | my ($self, $name) = @_; | |||||||||||||||||||
| 46 | 34 | ▶ | return $self->restricted->name() eq $name || $self->restricted->is_inside($name); | ||||||||||||||||||
|
Condition66%2/3
$self->restricted->name eq $name || $self->restricted->is_inside($name)
MC/DC50%1/2
$self->restricted->name eq $name || $self->restricted->is_inside($name)
$self->restricted->name eq $name
$self->restricted->is_inside($name)
Truth table66%2/3
A || B
A= $self->restricted->name eq $nameB= $self->restricted->is_inside($name)
| |||||||||||||||||||||
| 47 | } | ||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | =head2 has_property | ||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | See superclass Context. | ||||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | =cut | ||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | 40 | ▶ | sub has_property{ | ||||||||||||||||||
|
Subroutine
has_property: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||
| 56 | 40 | my ($self, $prop_name) = @_; | |||||||||||||||||||
| 57 | 40 | ▶ | return exists $self->properties()->{$prop_name} || $self->restricted->has_property($prop_name); | ||||||||||||||||||
|
Condition66%2/3
exists $self->properties->{$prop_name} || $self->restricted->has_property($prop_name)
MC/DC0%0/2
exists $self->properties->{$prop_name} || $self->restricted->has_property($prop_name)
exists $self->properties->{$prop_name}
$self->restricted->has_property($prop_name)
Truth table66%2/3
A || B
A= exists $self->properties->{$prop_name}B= $self->restricted->has_property($prop_name)
| |||||||||||||||||||||
| 58 | } | ||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | =head2 get_property | ||||||||||||||||||||
| 62 | |||||||||||||||||||||
| 63 | See Super Class. | ||||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | =cut | ||||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | 58 | ▶ | sub get_property{ | ||||||||||||||||||
|
Subroutine
get_property: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 68 | 58 | my ($self, $prop_name) = @_; | |||||||||||||||||||
| 69 | 58 | ▶ | if( exists $self->properties()->{$prop_name} ){ | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 70 | 24 | return $self->properties()->{$prop_name}; | |||||||||||||||||||
| 71 | } | ||||||||||||||||||||
| 72 | 34 | return $self->restricted()->get_property($prop_name); | |||||||||||||||||||
| 73 | } | ||||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | 2 | ▶ | sub _lookup_parents{ | ||||||||||||||||||
|
Subroutine
_lookup_parents: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 76 | 2 | my ($self,$propname) = @_; | |||||||||||||||||||
| 77 | 2 | return $self->restricted->lookup($propname); | |||||||||||||||||||
| 78 | } | ||||||||||||||||||||
| 79 | |||||||||||||||||||||
| 80 | 4 | __PACKAGE__->meta->make_immutable(); | |||||||||||||||||||
| 81 | 4 | 1; | |||||||||||||||||||