]> git.vpit.fr Git - perl/modules/LaTeX-TikZ.git/blobdiff - lib/LaTeX/TikZ/Meta/TypeConstraint/Autocoerce.pm
Just use Mouse instead of Any::Moose
[perl/modules/LaTeX-TikZ.git] / lib / LaTeX / TikZ / Meta / TypeConstraint / Autocoerce.pm
index 7671ade74ddbca7fb9538992ac72bb45ed295e75..dca3e69a36aab47468811f7586c376435a176105 100644 (file)
@@ -20,13 +20,13 @@ our $VERSION = '0.02';
     # The target class of the autocoercion (cannot be changed)
     {
      package X;
-     use Any::Moose;
+     use Mouse;
      has 'id' => (
       is  => 'ro',
       isa => 'Int',
      );
      use LaTeX::TikZ::Meta::TypeConstraint::Autocoerce;
-     use Any::Moose 'Util::TypeConstraints';
+     use Mouse::Util::TypeConstraints;
      register_type_constraint(
       LaTeX::TikZ::Meta::TypeConstraint::Autocoerce->new(
        name   => 'X::Autocoerce',
@@ -40,22 +40,20 @@ our $VERSION = '0.02';
     # The class that does the coercion (cannot be changed)
     {
      package Y;
-     use Any::Moose;
+     use Mouse;
      has 'x' => (
       is      => 'ro',
       isa     => 'X::Autocoerce',
       coerce  => 1,
       handles => [ 'id' ],
      );
-     # This class shouldn't be immutable when using Moose, or the
-     # coercing attributes will not be updated with the future coercions.
-     __PACKAGE__->meta->make_immutable if any_moose() ne 'Moose';
+     __PACKAGE__->meta->make_immutable;
     }
 
     # Another class the user wants to use instead of X (cannot be changed)
     {
      package Z;
-     use Any::Moose;
+     use Mouse;
      has 'id' => (
       is  => 'ro',
       isa => 'Num',
@@ -66,7 +64,7 @@ our $VERSION = '0.02';
     # The autocoercion class, defined by the user in X/From/Z.pm
     {
      package X::From::Z;
-     use Any::Moose 'Util::TypeConstraints';
+     use Mouse::Util::TypeConstraints;
      coerce 'X::Autocoerce'
          => from 'Z'
          => via { X->new(id => int $_->id) };
@@ -81,9 +79,9 @@ our $VERSION = '0.02';
 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>.
+It only supports L<Mouse> currently.
 
-Note that you will need L<Moose::Util::TypeConstraints/register_type_constraint> or L<Mouse::Util::TypeConstraints/register_type_constraint> to install this type constraint, and that the latter is only available starting L<Mouse> C<0.63>.
+Note that you will need L<Mouse::Util::TypeConstraints/register_type_constraint> to install this type constraint, which is only available starting L<Mouse> C<0.63>.
 
 =cut
 
@@ -93,15 +91,15 @@ use Sub::Name ();
 
 use LaTeX::TikZ::Tools;
 
-use Any::Moose;
+use Mouse;
 
 =head1 RELATIONSHIPS
 
-This class inherits from L<Moose::Meta::TypeConstraint> or L<Mouse::Meta::TypeConstraint>, depending on which mode L<Any::Moose> runs.
+This class inherits from L<Mouse::Meta::TypeConstraint>.
 
 =cut
 
-extends any_moose('Meta::TypeConstraint');
+extends 'Mouse::Meta::TypeConstraint';
 
 =head1 ATTRIBUTES
 
@@ -110,7 +108,7 @@ extends any_moose('Meta::TypeConstraint');
 The name of the type constraint.
 This must be the target of both the classes that want to use the autocoercion feature and the user defined coercions in the autoloaded classes.
 
-This attribute is inherited from the L<Moose> or L<Mouse> type constraint metaclass.
+This attribute is inherited from the L<Mouse> type constraint metaclass.
 
 =head2 C<mapper>
 
@@ -135,7 +133,7 @@ If it is given as a plain string, then a type constraint with the same name is s
 
 has 'target' => (
  is       => 'ro',
- isa      => any_moose('Meta::TypeConstraint'),
+ isa      => 'Mouse::Meta::TypeConstraint',
  required => 1,
 );
 
@@ -166,10 +164,6 @@ around 'new' => sub {
  $target_tc->assert_valid($target);
  $args{target} = $target;
 
- if (any_moose() eq 'Moose') {
-  $args{coercion} = Moose::Meta::TypeCoercion->new;
- }
-
  $args{constraint} = Sub::Name::subname('_constraint' => sub {
   my ($thing) = @_;
 
@@ -233,7 +227,7 @@ __PACKAGE__->meta->make_immutable(
 
 =head1 SEE ALSO
 
-L<Moose::Meta::TypeConstraint>, L<Mouse::Meta::TypeConstraint>.
+L<Mouse::Meta::TypeConstraint>.
 
 =head1 AUTHOR