| 1 | 31 | ▶ | use 5.008; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | 31 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 31 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | package Class::Scaffold::Base; | ||||||||||
| 6 | 31 | ▶ | BEGIN { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 31 | $Class::Scaffold::Base::VERSION = '1.102280'; | |||||||||
| 8 | } | ||||||||||
| 9 | |||||||||||
| 10 | # ABSTRACT: Base class for all classes of the class framework. | ||||||||||
| 11 | 31 | ▶ | use Data::Miscellany 'set_push'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 31 | ▶ | use Error::Hierarchy::Util 'load_class'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 31 | ▶ | use parent qw/ | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | Data::Inherited | ||||||||||
| 15 | Data::Comparable | ||||||||||
| 16 | Error::Hierarchy::Mixin | ||||||||||
| 17 | Class::Scaffold::Delegate::Mixin | ||||||||||
| 18 | Class::Scaffold::Accessor | ||||||||||
| 19 | Class::Scaffold::Factory::Type | ||||||||||
| 20 | 31 | /; | |||||||||
| 21 | |||||||||||
| 22 | # We subclass Class::Scaffold::Factory::Type so objects can introspect to see | ||||||||||
| 23 | # which object type they are. | ||||||||||
| 24 | 31 | __PACKAGE__->mk_constructor; | |||||||||
| 25 | |||||||||||
| 26 | # so every_hash has something to fall back to: | ||||||||||
| 27 | 0 | ▶ | sub FIRST_CONSTRUCTOR_ARGS { () } | ||||||||
|
Subroutine
FIRST_CONSTRUCTOR_ARGS: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 28 | |||||||||||
| 29 | # so everyone can call SUPER:: without worries, just pass through the args: | ||||||||||
| 30 | 0 | ▶ | sub MUNGE_CONSTRUCTOR_ARGS { | ||||||||
|
Subroutine
MUNGE_CONSTRUCTOR_ARGS: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 31 | 0 | my $self = shift; | |||||||||
| 32 | 0 | @_; | |||||||||
| 33 | } | ||||||||||
| 34 | 0 | ▶ | sub init { 1 } | ||||||||
|
Subroutine
init: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 35 | |||||||||||
| 36 | # Convenience method so subclasses don't need to say | ||||||||||
| 37 | # | ||||||||||
| 38 | # use Class::Scaffold::Log; | ||||||||||
| 39 | # my $log = Class::Scaffold::Log; | ||||||||||
| 40 | # $log->info(...); | ||||||||||
| 41 | # | ||||||||||
| 42 | # or | ||||||||||
| 43 | # | ||||||||||
| 44 | # Class::Scaffold::Log->debug(...); | ||||||||||
| 45 | # | ||||||||||
| 46 | # but can say | ||||||||||
| 47 | # | ||||||||||
| 48 | # $self->log->info(...); | ||||||||||
| 49 | # | ||||||||||
| 50 | # Eliminating fixed package names is also a way of decoupling; later on we | ||||||||||
| 51 | # might choose to get the log from the delegate or anywhere else, in which | ||||||||||
| 52 | # case we can make the change in one location - here. | ||||||||||
| 53 | # | ||||||||||
| 54 | # Class::Scaffold::Log inherits from this class, so we don't use() it but | ||||||||||
| 55 | # require() it, to avoid 'redefined' warnings. | ||||||||||
| 56 | 0 | ▶ | sub log { | ||||||||
|
Subroutine
log: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 57 | 0 | my $self = shift; | |||||||||
| 58 | 0 | require Class::Scaffold::Log; | |||||||||
| 59 | 0 | Class::Scaffold::Log->instance; | |||||||||
| 60 | } | ||||||||||
| 61 | |||||||||||
| 62 | # Try to load currently not loaded packages of the Class-Scaffold and other | ||||||||||
| 63 | # registered distributions and call the wanted method. | ||||||||||
| 64 | # | ||||||||||
| 65 | # Throw an exception if the package in which we have to look for the wanted | ||||||||||
| 66 | # method is already loaded (= the method doesn't exist). | ||||||||||
| 67 | 0 | ▶ | sub UNIVERSAL::DESTROY { } | ||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=0.0
| |||||||||||
| 68 | |||||||||||
| 69 | 0 | ▶ | sub UNIVERSAL::AUTOLOAD { | ||||||||
|
Subroutine
AUTOLOAD: not called CC=4 SCAR=27.3
| |||||||||||
| 70 | 0 | my ($pkg, $method) = ($UNIVERSAL::AUTOLOAD =~ /(.*)::(.*)/); | |||||||||
| 71 | 0 | local $" = '|'; | |||||||||
| 72 | 0 | our @autoload_packages; | |||||||||
| 73 | 0 | ▶ | unless ($pkg =~ /^(@autoload_packages)/) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 74 | |||||||||||
| 75 | # we don't deal with crappy external libs and | ||||||||||
| 76 | # their problems. get lost with your symbol. | ||||||||||
| 77 | 0 | require Carp; | |||||||||
| 78 | 0 | local $Carp::CarpLevel = 1; | |||||||||
| 79 | 0 | Carp::confess sprintf "Undefined subroutine &%s called", | |||||||||
| 80 | $UNIVERSAL::AUTOLOAD; | ||||||||||
| 81 | } | ||||||||||
| 82 | 0 | (my $key = "$pkg.pm") =~ s!::!/!g; | |||||||||
| 83 | 0 | local $Error::Depth = $Error::Depth + 1; | |||||||||
| 84 | 0 | ▶ | if (exists $INC{$key}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 85 | |||||||||||
| 86 | # package has been loaded already, so the method wanted | ||||||||||
| 87 | # doesn't seem to exist. | ||||||||||
| 88 | 0 | require Carp; | |||||||||
| 89 | 0 | local $Carp::CarpLevel = 1; | |||||||||
| 90 | 0 | Carp::confess sprintf "Undefined subroutine &%s called", | |||||||||
| 91 | $UNIVERSAL::AUTOLOAD; | ||||||||||
| 92 | } else { | ||||||||||
| 93 | 0 | load_class $pkg, 1; | |||||||||
| 94 | 31 | ▶ | no warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 95 | 0 | ▶ | if (my $coderef = UNIVERSAL::can($pkg, $method)) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 96 | 0 | goto &$coderef; | |||||||||
| 97 | } else { | ||||||||||
| 98 | 0 | require Carp; | |||||||||
| 99 | 0 | local $Carp::CarpLevel = 1; | |||||||||
| 100 | 0 | Carp::confess sprintf "Undefined subroutine &%s called", | |||||||||
| 101 | $UNIVERSAL::AUTOLOAD; | ||||||||||
| 102 | } | ||||||||||
| 103 | } | ||||||||||
| 104 | } | ||||||||||
| 105 | |||||||||||
| 106 | 8 | ▶ | sub add_autoloaded_package { | ||||||||
|
Subroutine
add_autoloaded_package: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 107 | 8 | ▶ | shift if $_[0] eq __PACKAGE__; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 108 | 8 | my $prefix = shift; | |||||||||
| 109 | 8 | our @autoload_packages; | |||||||||
| 110 | 8 | set_push @autoload_packages, $prefix; | |||||||||
| 111 | } | ||||||||||
| 112 | 31 | 1; | |||||||||
| 113 | |||||||||||
| 114 | |||||||||||
| 115 | __END__ | ||||||||||