[libmoox-late-perl] 06/08: use the new `dwim_type` function from Type::Utils
Intrigeri
intrigeri at moszumanska.debian.org
Thu Aug 14 11:13:50 UTC 2014
This is an automated email from the git hooks/post-receive script.
intrigeri pushed a commit to tag 0.013
in repository libmoox-late-perl.
commit 5195717e9efc5a88984303bb1c2948d2e0ec7ad7
Author: Toby Inkster <mail at tobyinkster.co.uk>
Date: Sat Jul 13 22:05:30 2013 +0100
use the new `dwim_type` function from Type::Utils
---
lib/MooX/late.pm | 9 ++------
lib/MooX/late/TypeRegistry.pm | 53 -------------------------------------------
meta/makefile.pret | 2 +-
3 files changed, 3 insertions(+), 61 deletions(-)
diff --git a/lib/MooX/late.pm b/lib/MooX/late.pm
index 36fc2fd..7ad3cf5 100644
--- a/lib/MooX/late.pm
+++ b/lib/MooX/late.pm
@@ -164,13 +164,8 @@ sub _handle_isa
my ($name, $spec, $context, $class) = @_;
return if ref $spec->{isa};
- my $reg = (
- $registry{$class} ||= do {
- require MooX::late::TypeRegistry;
- "MooX::late::TypeRegistry"->new(chained => $class);
- }
- );
- $spec->{isa} = $reg->lookup($spec->{isa});
+ require Type::Utils;
+ $spec->{isa} = Type::Utils::dwim_type($spec->{isa}, for => $class);
return;
}
diff --git a/lib/MooX/late/TypeRegistry.pm b/lib/MooX/late/TypeRegistry.pm
deleted file mode 100644
index 68493b4..0000000
--- a/lib/MooX/late/TypeRegistry.pm
+++ /dev/null
@@ -1,53 +0,0 @@
-## TODO - consider merging this into Type::Tiny somewhere.
-## Perhaps as Type::Util::dwim_lookup($type, %opts)???
-
-package MooX::late::TypeRegistry;
-
-use strict;
-use warnings;
-
-our $AUTHORITY = "cpan:TOBYINK";
-our $VERSION = "0.012";
-
-use base "Type::Registry";
-
-# Preload with standard types
-sub new
-{
- my ($class, %args) = @_;
- my $self = $class->SUPER::new(%args);
- $self->add_types(-Standard);
- # this hash key should never be used by the parent class
- $self->{"~~chained"} = $args{chained};
- return $self;
-}
-
-sub simple_lookup
-{
- my $self = shift;
-
- my $r = $self->SUPER::simple_lookup(@_);
- return $r if defined $r;
-
- # Chaining! This is a fallback which looks up the
- # type constraint in the class' Type::Registry if
- # we couldn't find it ourselves.
- #
- my $chained = "Type::Registry"->for_class($self->{"~~chained"});
- $r = eval { $chained->simple_lookup(@_) } unless $self == $chained;
- return $r if defined $r;
-
- # Lastly, if it looks like a class name, assume it's
- # supposed to be a class type.
- #
- if ($_[0] =~ /^\s*(\w+(::\w+)*)\s*$/sm)
- {
- require Type::Tiny::Class;
- return "Type::Tiny::Class"->new(class => $1);
- }
-
- # Give up already!
- return;
-}
-
-1;
diff --git a/meta/makefile.pret b/meta/makefile.pret
index 9fa403f..36a6db5 100644
--- a/meta/makefile.pret
+++ b/meta/makefile.pret
@@ -6,7 +6,7 @@
readme_from m`MooX::late`;
test_requires p`Test::More 0.61`;
requires p`Moo 1.002000`;
- requires p`Type::Registry 0.014`;
+ requires p`Type::Utils 0.015`;
recommends p`MooX`;
.
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libmoox-late-perl.git
More information about the Pkg-perl-cvs-commits
mailing list