| 1 | package UNIVERSAL::Object::Immutable; | ||||||||||||||||||||||
| 2 | # ABSTRACT: Another useful base class | ||||||||||||||||||||||
| 3 | 3 | ▶ | use 5.008; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 4 | 3 | ▶ | use strict; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 5 | 3 | ▶ | use warnings; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 6 | |||||||||||||||||||||||
| 7 | 3 | ▶ | use Carp (); | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 8 | 3 | ▶ | use overload (); | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 9 | 3 | ▶ | use Hash::Util (); | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 10 | 3 | ▶ | use Scalar::Util (); | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 11 | |||||||||||||||||||||||
| 12 | 3 | ▶ | use UNIVERSAL::Object; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 13 | |||||||||||||||||||||||
| 14 | 3 | our $VERSION = '0.15'; | |||||||||||||||||||||
| 15 | 3 | our $AUTHORITY = 'cpan:STEVAN'; | |||||||||||||||||||||
| 16 | |||||||||||||||||||||||
| 17 | 3 | ▶ | our @ISA; BEGIN { @ISA = ('UNIVERSAL::Object') } | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 18 | |||||||||||||||||||||||
| 19 | sub new { | ||||||||||||||||||||||
| 20 | 9 | ▶ | my $class = shift; | ||||||||||||||||||||
|
Subroutine
new: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||
| 21 | 9 | my $self = $class->SUPER::new( @_ ); | |||||||||||||||||||||
| 22 | 9 | my $repr = overload::StrVal($self); | |||||||||||||||||||||
| 23 | |||||||||||||||||||||||
| 24 | 9 | ▶ | if ( $repr =~ /\=HASH\(0x/ ) { | ||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||
| 25 | 4 | Hash::Util::lock_hash( %$self ); | |||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||
| 27 | elsif ( $repr =~ /\=ARRAY\(0x/ ) { | ||||||||||||||||||||||
| 28 | 1 | Internals::SvREADONLY( @$self, 1 ); | |||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||
| 30 | ▶ | elsif ( $repr =~ /\=SCALAR\(0x/ or $repr =~ /\=REF\(0x/ ) { | |||||||||||||||||||||
|
Condition100%3/3
$repr =~ /\=SCALAR\(0x/ or $repr =~ /\=REF\(0x/
MC/DC100%2/2
$repr =~ /\=SCALAR\(0x/ or $repr =~ /\=REF\(0x/
$repr =~ /\=SCALAR\(0x/
$repr =~ /\=REF\(0x/
Truth table100%3/3
A or B
A= $repr =~ /\=SCALAR\(0x/B= $repr =~ /\=REF\(0x/
| |||||||||||||||||||||||
| 31 | 2 | Internals::SvREADONLY( $$self, 1 ); | |||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||
| 33 | elsif ( $repr =~ /\=CODE\(0x/ ) { | ||||||||||||||||||||||
| 34 | # NOTE: do nothing here, because – ignoring | ||||||||||||||||||||||
| 35 | # closures – CODE refs are immutable anyway | ||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||
| 37 | else { | ||||||||||||||||||||||
| 38 | 1 | Carp::confess('Invalid BLESS args for '.Scalar::Util::blessed($self).', unsupported REPR type ('.Scalar::Util::reftype($self).')'); | |||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||
| 40 | |||||||||||||||||||||||
| 41 | 8 | return $self; | |||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||
| 43 | |||||||||||||||||||||||
| 44 | 3 | 1; | |||||||||||||||||||||
| 45 | |||||||||||||||||||||||
| 46 | __END__ | ||||||||||||||||||||||