| 1 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | |||||||||||
| 4 | package Pad::Tie::Plugin::Base::HashObjectAttr; | ||||||||||
| 5 | |||||||||||
| 6 | 1 | ▶ | use base 'Pad::Tie::Plugin'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use Carp (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | ▶ | use Devel::LexAlias (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 6 | ▶ | sub provides { | ||||||||
|
Subroutine
provides: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 11 | 6 | $_[0]->attr_type . '_attr' | |||||||||
| 12 | } | ||||||||||
| 13 | |||||||||||
| 14 | 0 | ▶ | sub sigil { | ||||||||
|
Subroutine
sigil: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 15 | 0 | Carp::confess "subclass $_[0] did not override virtual method 'sigil'" | |||||||||
| 16 | } | ||||||||||
| 17 | |||||||||||
| 18 | 3 | ▶ | sub build_attrs { | ||||||||
|
Subroutine
build_attrs: called CC=3 SCAR=11.2
Pod
undocumented
| |||||||||||
| 19 | 3 | my ($plugin, $ctx, $self, $args) = @_; | |||||||||
| 20 | |||||||||||
| 21 | 3 | $args = $plugin->canon_args($args); | |||||||||
| 22 | |||||||||||
| 23 | 3 | my $rv = { pre_call => [] }; | |||||||||
| 24 | |||||||||||
| 25 | 3 | my $sigil = $plugin->sigil; | |||||||||
| 26 | # XXX something isn't quite right here in the relationship between provides | ||||||||||
| 27 | # and the name of 'build_attrs' and ... | ||||||||||
| 28 | 3 | my ($attr_type) = $plugin->provides; | |||||||||
| 29 | 3 | for my $method (keys %$args) { | |||||||||
| 30 | 3 | my $name = $args->{$method}; | |||||||||
| 31 | 3 | my $var_name = "$sigil$name"; | |||||||||
| 32 | 3 | ▶ | if (exists $ctx->{$var_name}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | 0 | Carp::carp "removing existing context entry for $var_name; " . | |||||||||
| 34 | "adding entry for $attr_type => $method"; | ||||||||||
| 35 | 0 | delete $ctx->{$var_name}; | |||||||||
| 36 | } | ||||||||||
| 37 | $plugin->build_one_attr( | ||||||||||
| 38 | 3 | $ctx, $self, { | |||||||||
| 39 | method => $method, | ||||||||||
| 40 | name => $name, | ||||||||||
| 41 | }, | ||||||||||
| 42 | $rv, | ||||||||||
| 43 | ); | ||||||||||
| 44 | } | ||||||||||
| 45 | |||||||||||
| 46 | 3 | return $rv; | |||||||||
| 47 | } | ||||||||||
| 48 | |||||||||||
| 49 | 3 | ▶ | sub build_one_attr { | ||||||||
|
Subroutine
build_one_attr: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 50 | 3 | my ($plugin, $ctx, $self, $arg, $rv) = @_; | |||||||||
| 51 | 3 | my $sigil = $plugin->sigil; | |||||||||
| 52 | 3 | ▶ | push @{ $rv->{pre_call} }, sub { | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 53 | 27 | my ($self, $code, $args) = @_; | |||||||||
| 54 | 27 | Devel::LexAlias::lexalias( | |||||||||
| 55 | $code, | ||||||||||
| 56 | "$sigil$arg->{name}", | ||||||||||
| 57 | $plugin->ref_for_attr( | ||||||||||
| 58 | $ctx, | ||||||||||
| 59 | $self, | ||||||||||
| 60 | $arg, | ||||||||||
| 61 | ), | ||||||||||
| 62 | ); | ||||||||||
| 63 | 3 | }; | |||||||||
| 64 | } | ||||||||||
| 65 | |||||||||||
| 66 | 1 | 1; | |||||||||
| 67 | |||||||||||
| 68 | __END__ | ||||||||||