| 1 | package Catmandu::Fix::code; | ||
| 2 | |||
| 3 | 2 | ▶ | use Catmandu::Sane; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | |||
| 5 | 2 | our $VERSION = '1.0201_02'; | |
| 6 | |||
| 7 | 2 | ▶ | use Catmandu::Util qw(check_code_ref); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 2 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | 2 | with 'Catmandu::Fix::Inlineable'; | |
| 11 | |||
| 12 | has code => ( | ||
| 13 | is => 'ro', | ||
| 14 | default => sub { | ||
| 15 | ▶ | return sub { } | |
|
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||
| 16 | 0 | ▶ | }, |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 17 | 2 | isa => \&check_code_ref, | |
| 18 | ); | ||
| 19 | |||
| 20 | around BUILDARGS => sub { | ||
| 21 | 9 | ▶ | my ($orig, $class, $code) = @_; |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 22 | 9 | $orig->($class, code => $code); | |
| 23 | 2 | }; | |
| 24 | |||
| 25 | sub fix { | ||
| 26 | 723 | ▶ | my ($self, $data) = @_; |
|
Subroutine
fix: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 27 | 723 | $self->code->($data); | |
| 28 | } | ||
| 29 | |||
| 30 | 2 | 1; | |
| 31 | |||
| 32 | __END__ | ||
| 33 | |||
| 34 | =pod | ||
| 35 | |||
| 36 | =head1 NAME | ||
| 37 | |||
| 38 | Catmandu::Fix::code - run arbitrary code as fix | ||
| 39 | |||
| 40 | =head1 SYNOPSIS | ||
| 41 | |||
| 42 | my $fix = Catmandu::Fix::code->new( sub { | ||
| 43 | my ($data) = @_; | ||
| 44 | # ...do something | ||
| 45 | return $data; | ||
| 46 | }); | ||
| 47 | |||
| 48 | =head1 SEE ALSO | ||
| 49 | |||
| 50 | L<Catmandu::Fix::perlcode>, L<Catmandu::Fix::cmd> | ||
| 51 | |||
| 52 | =cut | ||