| 1 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||
| 2 | # GX Framework (c) 2009-2011 Jörg A. Uzarek <uzarek@runlevelnull.de> | ||||||||||
| 3 | # File: GX/Component/Singleton.pm | ||||||||||
| 4 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||
| 5 | |||||||||||
| 6 | package GX::Component::Singleton; | ||||||||||
| 7 | |||||||||||
| 8 | 38 | ▶ | use GX::Exception; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | |||||||||||
| 11 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||
| 12 | # Class setup | ||||||||||
| 13 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||
| 14 | |||||||||||
| 15 | 38 | ▶ | use GX::Class; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | |||||||||||
| 17 | 38 | extends qw( GX::Component GX::Class::Singleton ); | |||||||||
| 18 | |||||||||||
| 19 | 38 | build; | |||||||||
| 20 | |||||||||||
| 21 | |||||||||||
| 22 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||
| 23 | # Overloading | ||||||||||
| 24 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||
| 25 | |||||||||||
| 26 | use overload | ||||||||||
| 27 | 44 | ▶ | 'bool' => sub { 1 }, | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 28 | 0 | ▶ | '0+' => sub { $_[0] }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 29 | 32 | ▶ | '""' => sub { ref $_[0] }, | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 30 | 38 | 'fallback' => 1; | |||||||||
| 31 | |||||||||||
| 32 | |||||||||||
| 33 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||
| 34 | # Public methods | ||||||||||
| 35 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||
| 36 | |||||||||||
| 37 | 7 | ▶ | sub setup { | ||||||||
|
Subroutine
setup: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||
| 38 | |||||||||||
| 39 | 7 | my $self = shift->instance; | |||||||||
| 40 | |||||||||||
| 41 | 7 | my $class = ref $self; | |||||||||
| 42 | |||||||||||
| 43 | 7 | eval { | |||||||||
| 44 | 7 | $class->SUPER::setup( @_ ); | |||||||||
| 45 | }; | ||||||||||
| 46 | |||||||||||
| 47 | 7 | ▶ | if ( $@ ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 48 | 0 | complain $@; | |||||||||
| 49 | } | ||||||||||
| 50 | |||||||||||
| 51 | 7 | return; | |||||||||
| 52 | |||||||||||
| 53 | } | ||||||||||
| 54 | |||||||||||
| 55 | |||||||||||
| 56 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||
| 57 | # Private methods | ||||||||||
| 58 | # ---------------------------------------------------------------------------------------------------------------------- | ||||||||||
| 59 | |||||||||||
| 60 | 8 | ▶ | sub _component_interface { | ||||||||
|
Subroutine
_component_interface: called CC=1 SCAR=0.0
| |||||||||||
| 61 | |||||||||||
| 62 | 8 | return $_[0]->instance; | |||||||||
| 63 | |||||||||||
| 64 | } | ||||||||||
| 65 | |||||||||||
| 66 | 0 | ▶ | sub _unload { | ||||||||
|
Subroutine
_unload: not called CC=1 SCAR=6.9
| |||||||||||
| 67 | |||||||||||
| 68 | 0 | my $self = shift; | |||||||||
| 69 | |||||||||||
| 70 | 0 | $self->destroy; | |||||||||
| 71 | |||||||||||
| 72 | 0 | return; | |||||||||
| 73 | |||||||||||
| 74 | } | ||||||||||
| 75 | |||||||||||
| 76 | |||||||||||
| 77 | 38 | 1; | |||||||||
| 78 | |||||||||||
| 79 | __END__ | ||||||||||