| 1 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # GX Framework (c) 2009-2011 Jörg A. Uzarek <uzarek@runlevelnull.de> | ||||||||||||||||||||||||||||||||||||||||||
| 3 | # File: GX/Component.pm | ||||||||||||||||||||||||||||||||||||||||||
| 4 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | package GX::Component; | ||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 50 | ▶ | use GX::Callback::Method; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 50 | ▶ | use GX::Exception; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 50 | ▶ | use Scalar::Util qw( blessed ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 15 | # Constants | ||||||||||||||||||||||||||||||||||||||||||
| 16 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 50 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 50 | STATE_RELOADING => -1, | |||||||||||||||||||||||||||||||||||||||||
| 20 | STATE_INITIALIZED => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 21 | STATE_SETUP => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 22 | STATE_DEPLOYED => 2, | ||||||||||||||||||||||||||||||||||||||||||
| 23 | STATE_RUNNING => 3 | ||||||||||||||||||||||||||||||||||||||||||
| 24 | 50 | }; | |||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 28 | # Class setup | ||||||||||||||||||||||||||||||||||||||||||
| 29 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | 50 | ▶ | use GX::Class ( code_attributes => [ 'Handler' ] ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 50 | has static 'application' => ( | |||||||||||||||||||||||||||||||||||||||||
| 34 | isa => 'Scalar', | ||||||||||||||||||||||||||||||||||||||||||
| 35 | weaken => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 36 | accessors => { | ||||||||||||||||||||||||||||||||||||||||||
| 37 | 'application' => { type => 'get' }, | ||||||||||||||||||||||||||||||||||||||||||
| 38 | '_set_application' => { type => 'set' } | ||||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||
| 40 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | 50 | has static 'component_state' => ( | |||||||||||||||||||||||||||||||||||||||||
| 43 | isa => 'Scalar', | ||||||||||||||||||||||||||||||||||||||||||
| 44 | default => STATE_INITIALIZED, | ||||||||||||||||||||||||||||||||||||||||||
| 45 | accessors => { | ||||||||||||||||||||||||||||||||||||||||||
| 46 | '_get_component_state' => { type => 'get' }, | ||||||||||||||||||||||||||||||||||||||||||
| 47 | '_set_component_state' => { type => 'set' } | ||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||
| 49 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | 50 | has static 'config' => ( | |||||||||||||||||||||||||||||||||||||||||
| 52 | isa => 'Hash', | ||||||||||||||||||||||||||||||||||||||||||
| 53 | initializer => '_initialize_config', | ||||||||||||||||||||||||||||||||||||||||||
| 54 | accessors => { | ||||||||||||||||||||||||||||||||||||||||||
| 55 | '_get_config' => { type => 'get_reference' } | ||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||
| 57 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | 50 | has static 'handlers' => ( | |||||||||||||||||||||||||||||||||||||||||
| 60 | isa => 'Hash', | ||||||||||||||||||||||||||||||||||||||||||
| 61 | accessors => { | ||||||||||||||||||||||||||||||||||||||||||
| 62 | '_get_handlers' => { type => 'get_reference' } | ||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||
| 64 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 50 | build; | |||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 70 | # Public methods | ||||||||||||||||||||||||||||||||||||||||||
| 71 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | 7 | ▶ | sub setup { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setup: called CC=5 SCAR=18.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | 7 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 7 | ▶ | if ( ref $class ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | complain "setup() is a class method"; | |||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | 7 | ▶ | if ( @_ % 2 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | complain "Invalid number of arguments"; | |||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | 7 | ▶ | if ( $class->_is_setup ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | complain "$class has already been setup"; | |||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | 7 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 90 | 7 | $class->_component_interface->_setup( { @_ } ); | |||||||||||||||||||||||||||||||||||||||||
| 91 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | 7 | ▶ | if ( $@ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | GX::Exception->complain( | |||||||||||||||||||||||||||||||||||||||||
| 95 | message => "$class setup failed", | ||||||||||||||||||||||||||||||||||||||||||
| 96 | subexception => $@ | ||||||||||||||||||||||||||||||||||||||||||
| 97 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | 7 | $class->_is_setup( 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | 7 | return; | |||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 108 | # Internal methods | ||||||||||||||||||||||||||||||||||||||||||
| 109 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | sub __deploy { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__deploy: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | if ( $class->_is_deployed ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | if ( ! $class->application ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | complain "Cannot deploy $class (component has not been registered)"; | |||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | $class->_component_interface->_deploy; | |||||||||||||||||||||||||||||||||||||||||
| 125 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | if ( $@ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | GX::Exception->complain( | |||||||||||||||||||||||||||||||||||||||||
| 129 | message => "Cannot deploy $class", | ||||||||||||||||||||||||||||||||||||||||||
| 130 | subexception => $@ | ||||||||||||||||||||||||||||||||||||||||||
| 131 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | $class->_is_deployed( 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | sub __register { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__register: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | my $application = shift; | |||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | if ( ! blessed $application || ! $application->isa( 'GX::Application' ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
builtin::blessed($application) and $application->isa("GX::Application")
MC/DC0%0/2
builtin::blessed($application) and $application->isa("GX::Application")
builtin::blessed($application)
$application->isa("GX::Application")
Truth table0%0/3
A and B
A= builtin::blessed($application)B= $application->isa("GX::Application")
| |||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | complain "Invalid argument"; | |||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | if ( $class->application ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | if ( $class->application == $application ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | return $class->_component_interface; | |||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||
| 154 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | complain "Cannot register $class (already registered)"; | |||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | $class->__setup; | |||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | $class->_component_interface->_register( $application ); | |||||||||||||||||||||||||||||||||||||||||
| 164 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | if ( $@ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | GX::Exception->complain( | |||||||||||||||||||||||||||||||||||||||||
| 168 | message => "Cannot register $class", | ||||||||||||||||||||||||||||||||||||||||||
| 169 | subexception => $@ | ||||||||||||||||||||||||||||||||||||||||||
| 170 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | return $class->_component_interface; | |||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | sub __setup { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__setup: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | my $config = shift; | |||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | if ( defined $config && ref $config ne 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $config and ref $config ne "HASH"
MC/DC0%0/2
defined $config and ref $config ne "HASH"
defined $config
ref $config ne "HASH"
Truth table0%0/3
A and B
A= defined $configB= ref $config ne "HASH"
| |||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | complain "Invalid argument"; | |||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | if ( $class->_is_setup ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | ▶ | if ( defined $config ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | complain "$class has already been setup"; | |||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | $class->_component_interface->_setup( $config // {} ); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$config // {}
MC/DC0%0/1
$config // {}
$config
Truth table0%0/2
A
A= $config
| |||||||||||||||||||||||||||||||||||||||||||
| 198 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | if ( $@ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | GX::Exception->complain( | |||||||||||||||||||||||||||||||||||||||||
| 202 | message => "$class setup failed", | ||||||||||||||||||||||||||||||||||||||||||
| 203 | subexception => $@ | ||||||||||||||||||||||||||||||||||||||||||
| 204 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | $class->_is_setup( 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | ▶ | sub __start { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__start: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | ▶ | if ( $class->_is_running ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | if ( ! $class->_is_deployed ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | complain "Cannot start $class (component has not been deployed)"; | |||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | $class->_component_interface->_start; | |||||||||||||||||||||||||||||||||||||||||
| 227 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | if ( $@ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | GX::Exception->complain( | |||||||||||||||||||||||||||||||||||||||||
| 231 | message => "Cannot start $class", | ||||||||||||||||||||||||||||||||||||||||||
| 232 | subexception => $@ | ||||||||||||||||||||||||||||||||||||||||||
| 233 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | $class->_is_running( 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | sub __unload { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__unload: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | if ( $class->application ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | complain "Cannot unload $class (component is still registered)"; | |||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | $class->_component_interface->_unload; | |||||||||||||||||||||||||||||||||||||||||
| 252 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | if ( $@ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | GX::Exception->complain( | |||||||||||||||||||||||||||||||||||||||||
| 256 | message => "Cannot unload $class", | ||||||||||||||||||||||||||||||||||||||||||
| 257 | subexception => $@ | ||||||||||||||||||||||||||||||||||||||||||
| 258 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | ▶ | sub __unregister { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__unregister: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | if ( ! $class->application ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | $class->_component_interface->_unregister; | |||||||||||||||||||||||||||||||||||||||||
| 275 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | if ( $@ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | GX::Exception->complain( | |||||||||||||||||||||||||||||||||||||||||
| 279 | message => "Cannot unregister $class", | ||||||||||||||||||||||||||||||||||||||||||
| 280 | subexception => $@ | ||||||||||||||||||||||||||||||||||||||||||
| 281 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||
| 289 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 290 | # Private methods | ||||||||||||||||||||||||||||||||||||||||||
| 291 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||
| 293 | 1 | ▶ | sub _add_handler { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_add_handler: called CC=5 SCAR=19.4
| |||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||
| 295 | 1 | my $invocant = shift; | |||||||||||||||||||||||||||||||||||||||||
| 296 | 1 | my $hook_name = shift; | |||||||||||||||||||||||||||||||||||||||||
| 297 | 1 | my $handler = shift; | |||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||
| 299 | 1 | ▶ | if ( ! defined $hook_name || ! defined $handler ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $hook_name and defined $handler
MC/DC0%0/2
defined $hook_name and defined $handler
defined $hook_name
defined $handler
Truth table33%1/3
A and B
A= defined $hook_nameB= defined $handler
| |||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | complain "Missing argument"; | |||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||
| 303 | 1 | ▶ | if ( blessed $handler ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | ▶ | if ( ! $handler->isa( 'GX::Callback::Method' ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | complain "Invalid argument"; | |||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||
| 310 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 311 | 1 | $handler = $invocant->_create_handler( $handler ); | |||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||
| 314 | 1 | push @{$invocant->_get_handlers->{$hook_name}}, $handler; | |||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||
| 316 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | ▶ | sub _component_interface { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_component_interface: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | ▶ | return ref $_[0] || $_[0]; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $_[0] || $_[0]
MC/DC0%0/2
ref $_[0] || $_[0]
ref $_[0]
$_[0]
Truth table0%0/3
A || B
A= ref $_[0]B= $_[0]
| |||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||
| 326 | 1 | ▶ | sub _create_handler { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_create_handler: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||
| 328 | 1 | my $invocant = shift; | |||||||||||||||||||||||||||||||||||||||||
| 329 | 1 | my $method = shift; | |||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||
| 331 | 1 | return GX::Callback::Method->new( invocant => $invocant->_component_interface, method => $method ); | |||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | ▶ | sub _deploy { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_deploy: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||
| 337 | # Abstract method | ||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | ▶ | sub _export_attribute { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_export_attribute: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | my $invocant = shift; | |||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | my $importer = shift; | |||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | my $attribute = shift; | |||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | ▶ | if ( ! defined $importer || ! defined $attribute ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $importer and defined $attribute
MC/DC0%0/2
defined $importer and defined $attribute
defined $importer
defined $attribute
Truth table0%0/3
A and B
A= defined $importerB= defined $attribute
| |||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | complain "Missing or invalid argument"; | |||||||||||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | ▶ | if ( ! eval { $importer->isa( 'GX::Class' ) } ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | complain "Cannot export attribute ($importer is not a GX::Class)"; | |||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | ▶ | if ( ref $attribute eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | $attribute = $importer->meta->add_attribute( %$attribute ); | |||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||
| 360 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | $attribute = $importer->meta->add_attribute( $attribute ); | |||||||||||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | $attribute->install; | |||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | ▶ | if ( $importer->can( '__build' ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | $importer->__build; | |||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||
| 370 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | ▶ | if ( $@ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | GX::Exception->complain( | |||||||||||||||||||||||||||||||||||||||||
| 374 | message => "Cannot export attribute", | ||||||||||||||||||||||||||||||||||||||||||
| 375 | subexception => $@ | ||||||||||||||||||||||||||||||||||||||||||
| 376 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | ▶ | sub _export_method { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_export_method: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | my $invocant = shift; | |||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | my $importer = shift; | |||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | my $method = shift; | |||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | my $code = shift; | |||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | ▶ | if ( ! defined $importer || ! defined $method || ! defined $code ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $importer and defined $method and defined $code
defined $importer and defined $method
MC/DC0%0/3
defined $importer and defined $method and defined $code
defined $importer
defined $method
defined $code
Truth table0%0/4
A and B and C
A= defined $importerB= defined $methodC= defined $code
| |||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | complain "Missing or invalid argument"; | |||||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | ▶ | if ( ! eval { $importer->isa( 'GX::Class' ) } ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | complain "Cannot export method ($importer is not a GX::Class)"; | |||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | $importer->meta->add_method( $method, $code ); | |||||||||||||||||||||||||||||||||||||||||
| 400 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | ▶ | if ( $@ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | GX::Exception->complain( | |||||||||||||||||||||||||||||||||||||||||
| 404 | message => "Cannot export method", | ||||||||||||||||||||||||||||||||||||||||||
| 405 | subexception => $@ | ||||||||||||||||||||||||||||||||||||||||||
| 406 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||
| 413 | 4 | ▶ | sub _initialize_config { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_initialize_config: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||
| 415 | 4 | return {}; | |||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||
| 419 | 67 | ▶ | sub _install_import_method { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_install_import_method: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||
| 421 | 67 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||
| 423 | 67 | ▶ | return if $class eq __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||
| 425 | $class->meta->add_method( | ||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||
| 427 | 43 | ▶ | 'import' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.4
| |||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||
| 429 | 43 | my $package = shift; | |||||||||||||||||||||||||||||||||||||||||
| 430 | 43 | my $caller = caller; | |||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||
| 432 | 43 | ▶ | return if $package ne $class || $caller eq 'main'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$package ne $class or $caller eq "main"
MC/DC50%1/2
$package ne $class or $caller eq "main"
$package ne $class
$caller eq "main"
Truth table66%2/3
A or B
A= $package ne $classB= $caller eq "main"
| |||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||
| 434 | 40 | ▶ | if ( ! $package->_validate_class_name( $caller ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | complain "Cannot import $package (\"$caller\" is not a valid class name for a $package component)"; | |||||||||||||||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||
| 438 | 40 | for my $pragma ( qw( strict warnings ) ) { | |||||||||||||||||||||||||||||||||||||||||
| 439 | 80 | $pragma->import; | |||||||||||||||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||
| 442 | 40 | my $meta = GX::Meta::Class->new( $caller ); | |||||||||||||||||||||||||||||||||||||||||
| 443 | 40 | $meta->inherit_from( $package ); | |||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||
| 445 | 40 | return; | |||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||
| 447 | } | ||||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||
| 449 | 67 | ); | |||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||
| 451 | 67 | return; | |||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||
| 453 | } | ||||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | ▶ | sub _is_deployed { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_deployed: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | my $invocant = shift; | |||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | ▶ | if ( $_[0] ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | $invocant->_set_component_state( STATE_DEPLOYED ); | |||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 462 | } | ||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | return $invocant->_get_component_state >= STATE_DEPLOYED; | |||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||
| 466 | } | ||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | ▶ | sub _is_initialized { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_initialized: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | my $invocant = shift; | |||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | ▶ | if ( $_[0] ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | $invocant->_set_component_state( STATE_INITIALIZED ); | |||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | return $invocant->_get_component_state >= STATE_INITIALIZED; | |||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||
| 479 | } | ||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | ▶ | sub _is_reloading { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_reloading: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | my $invocant = shift; | |||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | ▶ | if ( $_[0] ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | $invocant->_set_component_state( STATE_RELOADING ); | |||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 488 | } | ||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | return $invocant->_get_component_state == STATE_RELOADING; | |||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | ▶ | sub _is_running { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_running: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | my $invocant = shift; | |||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | ▶ | if ( $_[0] ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | $invocant->_set_component_state( STATE_RUNNING ); | |||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | return $invocant->_get_component_state >= STATE_RUNNING; | |||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||
| 507 | 14 | ▶ | sub _is_setup { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_setup: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||
| 509 | 14 | my $invocant = shift; | |||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||
| 511 | 14 | ▶ | if ( $_[0] ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 512 | 7 | $invocant->_set_component_state( STATE_SETUP ); | |||||||||||||||||||||||||||||||||||||||||
| 513 | 7 | return; | |||||||||||||||||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||
| 516 | 7 | return $invocant->_get_component_state >= STATE_SETUP; | |||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||
| 518 | } | ||||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | ▶ | sub _register { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_register: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | my $invocant = shift; | |||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | my $application = shift; | |||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | $invocant->_set_application( $application ); | |||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | $invocant->_register_handlers; | |||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||
| 531 | } | ||||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | ▶ | sub _register_handlers { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_register_handlers: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | my $invocant = shift; | |||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | my $handlers = $invocant->_get_handlers; | |||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | ▶ | while ( my ( $hook_name, $handlers ) = each %$handlers ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | ▶ | if ( my $hook = $invocant->application->hook( $hook_name ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | for my $handler ( @$handlers ) { | |||||||||||||||||||||||||||||||||||||||||
| 544 | 0 | $hook->add( $handler ); | |||||||||||||||||||||||||||||||||||||||||
| 545 | } | ||||||||||||||||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||||||||||||||||
| 547 | } | ||||||||||||||||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||||||||||||||||
| 549 | } | ||||||||||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||
| 553 | } | ||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||
| 555 | 7 | ▶ | sub _setup { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_setup: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||
| 557 | 7 | my $invocant = shift; | |||||||||||||||||||||||||||||||||||||||||
| 558 | 7 | my $config = shift; | |||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||
| 560 | 7 | $invocant->_setup_config( $config ); | |||||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||||||
| 562 | 7 | $invocant->_setup_handlers; | |||||||||||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||||||||||||
| 564 | 7 | return; | |||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||
| 566 | } | ||||||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||||||
| 568 | 6 | ▶ | sub _setup_config { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_setup_config: called CC=3 SCAR=12.3
| |||||||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||||||
| 570 | 6 | my $invocant = shift; | |||||||||||||||||||||||||||||||||||||||||
| 571 | 6 | my $config = shift; | |||||||||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||||||||||
| 573 | 6 | $invocant->_get_config; # initialize | |||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||
| 575 | 6 | ▶ | if ( $config && %$config ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$config and %$config
MC/DC0%0/2
$config and %$config
$config
%$config
Truth table33%1/3
A and B
A= $configB= %$config
| |||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | throw sprintf( "Unrecognized setup option (\"%s\")", ( sort keys %$config )[0] ); | |||||||||||||||||||||||||||||||||||||||||
| 577 | } | ||||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||
| 579 | 6 | return; | |||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||
| 581 | } | ||||||||||||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||||||||||||
| 583 | 7 | ▶ | sub _setup_handlers { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_setup_handlers: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||||||
| 585 | 7 | my $invocant = shift; | |||||||||||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||||||||||||
| 587 | 7 | $invocant->_get_handlers; # initialize | |||||||||||||||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||||||||||||||||
| 589 | 7 | for my $method ( $invocant->meta->all_methods ) { | |||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||
| 591 | 607 | for my $attribute ( $method->code_attributes ) { | |||||||||||||||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||||||||||||||||
| 593 | 1 | ▶ | if ( $attribute =~ /^Handler\(\s?(\w+?)\s?\)$/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 594 | 1 | $invocant->_add_handler( $1, $method->name ); | |||||||||||||||||||||||||||||||||||||||||
| 595 | } | ||||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||||
| 597 | } | ||||||||||||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||||||||||||
| 599 | } | ||||||||||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||||||||||
| 601 | 7 | return; | |||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||
| 603 | } | ||||||||||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | ▶ | sub _start { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_start: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||||||||
| 607 | # Abstract method | ||||||||||||||||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||||||||||||||||
| 609 | } | ||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||
| 611 | 0 | ▶ | sub _unload { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_unload: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||||||||||||||||
| 613 | # Abstract method | ||||||||||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||||||||||
| 615 | } | ||||||||||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||||||||||
| 617 | 0 | ▶ | sub _unregister { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_unregister: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | my $invocant = shift; | |||||||||||||||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||||||||||||||||
| 621 | 0 | $invocant->_unregister_handlers; | |||||||||||||||||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||||||||||||||||
| 623 | 0 | $invocant->_set_application( undef ); | |||||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||||||
| 625 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||
| 627 | } | ||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||
| 629 | 0 | ▶ | sub _unregister_handlers { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_unregister_handlers: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 630 | |||||||||||||||||||||||||||||||||||||||||||
| 631 | 0 | my $invocant = shift; | |||||||||||||||||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | my $handlers = $invocant->_get_handlers; | |||||||||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||||||||||
| 635 | 0 | ▶ | while ( my ( $hook_name, $handlers ) = each %$handlers ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||||||||||||||||
| 637 | 0 | ▶ | if ( my $hook = $invocant->application->hook( $hook_name ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||||||||||||||||
| 639 | 0 | for my $handler ( @$handlers ) { | |||||||||||||||||||||||||||||||||||||||||
| 640 | 0 | $hook->remove( $handler ); | |||||||||||||||||||||||||||||||||||||||||
| 641 | } | ||||||||||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||||||||||
| 643 | } | ||||||||||||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||||||||||||
| 645 | } | ||||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||||
| 647 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||||||||||||
| 649 | } | ||||||||||||||||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||||||||||||||||
| 651 | 0 | ▶ | sub _validate_class_name { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_validate_class_name: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||||||||||||||||
| 653 | # Abstract method | ||||||||||||||||||||||||||||||||||||||||||
| 654 | |||||||||||||||||||||||||||||||||||||||||||
| 655 | } | ||||||||||||||||||||||||||||||||||||||||||
| 656 | |||||||||||||||||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||||||||||||||||
| 658 | 50 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||||||||||||||||
| 660 | __END__ | ||||||||||||||||||||||||||||||||||||||||||