| 1 | package Data::Sah::Compiler::perl::TH::re; | ||
| 2 | |||
| 3 | 2 | ▶ | use 5.010; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 2 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 2 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | #use Log::Any '$log'; | ||
| 7 | |||
| 8 | 2 | ▶ | use Mo qw(build default); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | 2 | ▶ | use Role::Tiny::With; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | |||
| 11 | 2 | extends 'Data::Sah::Compiler::perl::TH'; | |
| 12 | 2 | with 'Data::Sah::Type::re'; | |
| 13 | |||
| 14 | 2 | our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY | |
| 15 | 2 | our $DATE = '2024-02-16'; # DATE | |
| 16 | 2 | our $DIST = 'Data-Sah'; # DIST | |
| 17 | 2 | our $VERSION = '0.917'; # VERSION | |
| 18 | |||
| 19 | # XXX prefilter to convert string to regex object | ||
| 20 | |||
| 21 | 6 | ▶ | sub handle_type { |
|
Subroutine
handle_type: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 22 | 6 | my ($self, $cd) = @_; | |
| 23 | 6 | my $c = $self->compiler; | |
| 24 | |||
| 25 | 6 | my $dt = $cd->{data_term}; | |
| 26 | 6 | $cd->{_ccl_check_type} = "ref($dt) eq 'Regexp' || !ref($dt) && ". | |
| 27 | "eval { my \$_sahv_re = $dt; qr/\$_sahv_re/; 1 }"; | ||
| 28 | } | ||
| 29 | |||
| 30 | 2 | 1; | |
| 31 | # ABSTRACT: perl's type handler for type "re" | ||
| 32 | |||
| 33 | __END__ | ||