From: Vincent Pit Date: Tue, 6 Aug 2013 14:36:58 +0000 (-0300) Subject: Factor the 'target' type constraint outside of L::T::M::TC::A->new X-Git-Tag: rt87282~3 X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FLaTeX-TikZ.git;a=commitdiff_plain;h=c3b268a795d0378bc3b2a73f8755af80df78b542 Factor the 'target' type constraint outside of L::T::M::TC::A->new --- diff --git a/lib/LaTeX/TikZ/Meta/TypeConstraint/Autocoerce.pm b/lib/LaTeX/TikZ/Meta/TypeConstraint/Autocoerce.pm index 25f3879..00fbbf4 100644 --- a/lib/LaTeX/TikZ/Meta/TypeConstraint/Autocoerce.pm +++ b/lib/LaTeX/TikZ/Meta/TypeConstraint/Autocoerce.pm @@ -137,6 +137,9 @@ has 'target' => ( required => 1, ); +my $target_tc = __PACKAGE__->meta->find_attribute_by_name('target') + ->type_constraint; + =head2 C An optional user defined code reference which predates checking the target for validity. @@ -169,8 +172,7 @@ around 'new' => sub { $target = LaTeX::TikZ::Tools::type_constraint($target) if defined $target; Carp::confess("No meta object for $target_name") unless defined $target; } - __PACKAGE__->meta->find_attribute_by_name('target') - ->type_constraint->assert_valid($target); + $target_tc->assert_valid($target); $args{target} = $target; if (any_moose() eq 'Moose') {