From: Lukas Mai Date: Wed, 28 Aug 2013 18:01:08 +0000 (+0200) Subject: Revert "simplify dual Moo/Moose logic a bit" X-Git-Tag: v1.0202~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1f8c776ed00b3f61a0404973643163423d7c7bdd;hp=13a9d4474a2eb95e4d84d546a2bcf4a976213452;p=p5sagit%2FFunction-Parameters.git Revert "simplify dual Moo/Moose logic a bit" This reverts commit 47ba782a13ecd4060c36205fde63412ec2b2f601. This way we don't require a modern Moo with ->meta support. --- diff --git a/lib/Function/Parameters/Info.pm b/lib/Function/Parameters/Info.pm index ffec607..6c624ff 100644 --- a/lib/Function/Parameters/Info.pm +++ b/lib/Function/Parameters/Info.pm @@ -6,13 +6,15 @@ use warnings; our $VERSION = '0.04'; # If Moo isn't loaded yet but Moose is, avoid pulling in Moo and fall back to Moose -my $Moo; +my ($Moo, $meta_make_immutable); BEGIN { if ($INC{'Moose.pm'} && !$INC{'Moo.pm'}) { $Moo = 'Moose'; + $meta_make_immutable = sub { $_[0]->meta->make_immutable }; } else { require Moo; $Moo = 'Moo'; + $meta_make_immutable = sub {}; } $Moo->import; } @@ -28,7 +30,7 @@ BEGIN { has $_ => (is => 'ro') for qw(name type); - __PACKAGE__->meta->make_immutable; + __PACKAGE__->$meta_make_immutable; } my @pn_ro = glob '{positional,named}_{required,optional}'; @@ -62,7 +64,7 @@ sub args_max { $r } -__PACKAGE__->meta->make_immutable; +__PACKAGE__->$meta_make_immutable; 'ok'