| 1 | #!perl | ||||||||||
| 2 | #PODNAME: Raisin::Plugin | ||||||||||
| 3 | #ABSTRACT: Base class for Raisin plugins | ||||||||||
| 4 | |||||||||||
| 5 | 14 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 14 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | package Raisin::Plugin; | ||||||||||
| 9 | 14 | $Raisin::Plugin::VERSION = '0.94'; | |||||||||
| 10 | 14 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 11 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 13 | 11 | my ($class, $app) = @_; | |||||||||
| 14 | 11 | my $self = bless {}, $class; | |||||||||
| 15 | 11 | $self->{app} = $app; | |||||||||
| 16 | 11 | $self; | |||||||||
| 17 | } | ||||||||||
| 18 | |||||||||||
| 19 | 57 | ▶ | sub app { shift->{app} } | ||||||||
|
Subroutine
app: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 20 | |||||||||||
| 21 | 1 | ▶ | sub build { | ||||||||
|
Subroutine
build: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 22 | 1 | my ($self, %args) = @_; | |||||||||
| 23 | } | ||||||||||
| 24 | |||||||||||
| 25 | 10 | ▶ | sub register { | ||||||||
|
Subroutine
register: called CC=6 SCAR=19.4
Pod
documented
| |||||||||||
| 26 | 10 | my ($self, %items) = @_; | |||||||||
| 27 | |||||||||||
| 28 | 10 | ▶ | while (my ($name, $item) = each %items) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 29 | 14 | ▶ | no strict 'refs'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 30 | #no warnings 'redefine'; | ||||||||||
| 31 | |||||||||||
| 32 | 16 | my $class = ref $self->app; | |||||||||
| 33 | 16 | my $caller = $self->app->{caller}; | |||||||||
| 34 | |||||||||||
| 35 | 16 | my $glob = "${class}::${name}"; | |||||||||
| 36 | 16 | ▶ | my $app_glob = $caller ? "${caller}::${name}" : undef; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 37 | |||||||||||
| 38 | 16 | ▶ | if ($self->app->can($name)) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 39 | 0 | croak "Redefining of $glob not allowed"; | |||||||||
| 40 | } | ||||||||||
| 41 | |||||||||||
| 42 | 16 | ▶ | if (ref $item eq 'CODE') { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 43 | 16 | *{$glob} = $item; | |||||||||
| 44 | 16 | ▶ | *{$app_glob} = $item if $app_glob; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 45 | } | ||||||||||
| 46 | else { | ||||||||||
| 47 | 0 | $self->app->{$name} = $item; | |||||||||
| 48 | 0 | ▶ | *{$glob} = sub { shift->{$name} }; | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 49 | } | ||||||||||
| 50 | } | ||||||||||
| 51 | } | ||||||||||
| 52 | |||||||||||
| 53 | 14 | 1; | |||||||||
| 54 | |||||||||||
| 55 | __END__ | ||||||||||