[libtype-tiny-perl] 04/07: lazy load Type::Tiny::Union in Type::Params
Jonas Smedegaard
dr at jones.dk
Wed Oct 29 19:42:45 UTC 2014
This is an automated email from the git hooks/post-receive script.
js pushed a commit to tag 1.001_001
in repository libtype-tiny-perl.
commit 45743f0f7b2c2b508164fc1fedf176bbc1c56e5b
Author: Toby Inkster <mail at tobyinkster.co.uk>
Date: Fri Sep 19 01:19:15 2014 +0100
lazy load Type::Tiny::Union in Type::Params
---
lib/Type/Params.pm | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/lib/Type/Params.pm b/lib/Type/Params.pm
index 2553d0b..1042209 100644
--- a/lib/Type/Params.pm
+++ b/lib/Type/Params.pm
@@ -19,7 +19,6 @@ use Scalar::Util qw(refaddr);
use Error::TypeTiny;
use Error::TypeTiny::Assertion;
use Error::TypeTiny::WrongNumberOfParameters;
-use Type::Tiny::Union;
use Types::Standard -types;
use Types::TypeTiny qw(CodeLike ArrayLike to_TypeTiny);
@@ -29,13 +28,22 @@ our @ISA = 'Exporter::Tiny';
our @EXPORT = qw( compile compile_named );
our @EXPORT_OK = qw( multisig validate validate_named Invocant );
-BEGIN {
- my $Invocant = 'Type::Tiny::Union'->new(
- name => 'Invocant',
- type_constraints => [Object, ClassName],
- );
- sub Invocant () { $Invocant };
-};
+{
+ my $Invocant;
+ sub Invocant () {
+ $Invocant ||= do {
+ require Type::Tiny::Union;
+ require Types::Standard;
+ 'Type::Tiny::Union'->new(
+ name => 'Invocant',
+ type_constraints => [
+ Types::Standard::Object(),
+ Types::Standard::ClassName(),
+ ],
+ );
+ };
+ }
+}
sub _mkslurpy
{
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libtype-tiny-perl.git
More information about the Pkg-perl-cvs-commits
mailing list