Data-Sah-Resolve
view release on metacpan or search on metacpan
lib/Data/Sah/Resolve.pm view on Meta::CPAN
eval { require $typemod_pm; 1 };
my $err = $@;
unless ($err) {
# already a builtin-type, so we stop here
return;
}
die "Cannot resolve Sah schema: can't check whether $type is a builtin Sah type: $err"
unless $err =~ /\ACan't locate/;
# not a type, try a schema under Sah::Schema
my $schmod = "Sah::Schema::$type";
(my $schmod_pm = "$schmod.pm") =~ s!::!/!g;
eval { require $schmod_pm; 1 };
die "Cannot resolve Sah schema: not a known built-in Sah type '$type' (can't locate ".
"Data::Sah::Type::$type) and not a known schema name '$type' ($@)"
if $@;
no strict 'refs';
my $sch2 = ${"$schmod\::schema"};
die "Cannot resolve Sah schema: BUG: Schema module $schmod doesn't contain \$schema"
unless $sch2;
$res->{type} = $sch2->[0];
unshift @{ $res->{clsets_after_type} }, $sch2->[1];
_resolve($opts, $res);
}
sub resolve_schema {
my $opts = ref($_[0]) eq 'HASH' ? shift : {};
my $sch = shift;
( run in 0.390 second using v1.01-cache-2.11-cpan-8d75d55dd25 )