]> git.vpit.fr Git - perl/modules/LaTeX-TikZ.git/commitdiff
Factor the 'target' type constraint outside of L::T::M::TC::A->new
authorVincent Pit <vince@profvince.com>
Tue, 6 Aug 2013 14:36:58 +0000 (11:36 -0300)
committerVincent Pit <vince@profvince.com>
Tue, 6 Aug 2013 14:36:58 +0000 (11:36 -0300)
lib/LaTeX/TikZ/Meta/TypeConstraint/Autocoerce.pm

index 25f3879a6fcb39f57b573eb86d40173e51807f1c..00fbbf4a547ac485aa787a15defb9fdc92d651d2 100644 (file)
@@ -137,6 +137,9 @@ has 'target' => (
  required => 1,
 );
 
+my $target_tc = __PACKAGE__->meta->find_attribute_by_name('target')
+                                 ->type_constraint;
+
 =head2 C<user_constraint>
 
 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') {