| 1 | package Util::Underscore::Objects; | ||||||||||
| 2 | |||||||||||
| 3 | #ABSTRACT: Functions for introspecting and manipulating objects and classes | ||||||||||
| 4 | |||||||||||
| 5 | 12 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 12 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | |||||||||||
| 9 | ## no critic (ProhibitMultiplePackages) | ||||||||||
| 10 | package # hide from PAUSE | ||||||||||
| 11 | _; | ||||||||||
| 12 | |||||||||||
| 13 | ## no critic (RequireArgUnpacking, RequireFinalReturn, ProhibitSubroutinePrototypes) | ||||||||||
| 14 | |||||||||||
| 15 | sub blessed(_) { | ||||||||||
| 16 | 138 | ▶ | goto &Scalar::Util::blessed; | ||||||||
|
Subroutine
blessed: called CC=1 SCAR=0.0
| |||||||||||
| 17 | } | ||||||||||
| 18 | |||||||||||
| 19 | { | ||||||||||
| 20 | 12 | ▶ | no warnings 'once'; ## no critic (ProhibitNoWarnings) | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | 12 | *class = \&blessed; | |||||||||
| 22 | } | ||||||||||
| 23 | |||||||||||
| 24 | sub is_object(_) { | ||||||||||
| 25 | 11 | ▶ | defined blessed $_[0]; | ||||||||
|
Subroutine
is_object: called CC=1 SCAR=0.0
| |||||||||||
| 26 | } | ||||||||||
| 27 | |||||||||||
| 28 | sub class_isa($$) { | ||||||||||
| 29 | 4 | ▶ | is_package($_[0]) | ||||||||
|
Subroutine
class_isa: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||
| 30 | && $_[0]->isa($_[1]); | ||||||||||
| 31 | } | ||||||||||
| 32 | |||||||||||
| 33 | sub class_does($$) { | ||||||||||
| 34 | 4 | ▶ | is_package($_[0]) | ||||||||
|
Subroutine
class_does: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||
| 35 | && $_[0]->DOES($_[1]); | ||||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | sub class_can($$) { | ||||||||||
| 39 | 4 | ▶ | is_package($_[0]) | ||||||||
|
Subroutine
class_can: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||
| 40 | && $_[0]->can($_[1]); | ||||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | sub isa($$) { | ||||||||||
| 44 | 4 | ▶ | blessed $_[0] | ||||||||
|
Subroutine
isa: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||
| 45 | && $_[0]->isa($_[1]); | ||||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | sub does($$) { | ||||||||||
| 49 | 4 | ▶ | blessed $_[0] | ||||||||
|
Subroutine
does: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||
| 50 | && $_[0]->DOES($_[1]); | ||||||||||
| 51 | } | ||||||||||
| 52 | |||||||||||
| 53 | { | ||||||||||
| 54 | 12 | ▶ | no warnings 'once'; ## no critic (ProhibitNoWarnings) | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 55 | 12 | *is_instance = \&does; | |||||||||
| 56 | } | ||||||||||
| 57 | |||||||||||
| 58 | sub can($$) { | ||||||||||
| 59 | 4 | ▶ | blessed $_[0] | ||||||||
|
Subroutine
can: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||
| 60 | && $_[0]->can($_[1]); | ||||||||||
| 61 | } | ||||||||||
| 62 | |||||||||||
| 63 | sub safecall($$@) { | ||||||||||
| 64 | 11 | ▶ | my $self = shift; | ||||||||
|
Subroutine
safecall: called CC=2 SCAR=6.9
| |||||||||||
| 65 | 11 | my $meth = shift; | |||||||||
| 66 | 11 | ▶ | return if not blessed $self; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 67 | 5 | $self->$meth(@_); | |||||||||
| 68 | } | ||||||||||
| 69 | |||||||||||
| 70 | 12 | 1; | |||||||||
| 71 | |||||||||||
| 72 | __END__ | ||||||||||