]> git.vpit.fr Git - perl/modules/LaTeX-TikZ.git/blobdiff - lib/LaTeX/TikZ/Meta/TypeConstraint/Autocoerce.pm
Switch to qw<>
[perl/modules/LaTeX-TikZ.git] / lib / LaTeX / TikZ / Meta / TypeConstraint / Autocoerce.pm
index f335cb95f108fd787c4a82a5efba913713f43bdf..72bb96fa5a34e269f9664cfd13495cfa30a36e55 100644 (file)
@@ -76,7 +76,7 @@ our $VERSION = '0.02';
 
 =head1 DESCRIPTION
 
-This type constraint metaclass tries to autoload a specific module when a type coercion is attempted, which is supposed to contain the actual coercion code.
+When a type coercion is attempted, this type constraint metaclass tries to autoload a specific module which is supposed to contain the actual coercion code.
 This allows you to declare types that can be replaced (through coercion) at the end user's discretion.
 
 It works with both L<Moose> and L<Mouse> by using L<Any::Moose>.
@@ -85,12 +85,13 @@ Note that you will need L<Moose::Util::TypeConstraints/register_type_constraint>
 
 =cut
 
-use Scalar::Util qw/blessed/;
+use Scalar::Util qw<blessed>;
 
 use Sub::Name ();
 
+use LaTeX::TikZ::Tools;
+
 use Any::Moose;
-use Any::Moose 'Util' => [ 'find_meta' ];
 
 =head1 RELATIONSHIPS
 
@@ -163,10 +164,10 @@ around 'new' => sub {
  }
 
  my $parent = delete $args{parent};
- unless (defined $parent and blessed $parent) {
-  $parent = find_meta($parent);
-  Carp::confess("No meta object for parent $parent");
-  $parent = $parent->type_constraint;
+ unless (blessed $parent) {
+  my $parent_name = defined $parent ? "parent $parent" : 'undefined parent';
+  $parent = LaTeX::TikZ::Tools::type_constraint($parent) if defined $parent;
+  Carp::confess("No meta object for $parent_name")   unless defined $parent;
  }
  __PACKAGE__->meta->find_attribute_by_name('parent')
                   ->type_constraint->assert_valid($parent);