]> git.vpit.fr Git - perl/modules/LaTeX-TikZ.git/blobdiff - lib/LaTeX/TikZ/Point.pm
Make Points into a real class
[perl/modules/LaTeX-TikZ.git] / lib / LaTeX / TikZ / Point.pm
index f2155e8ff75b151ef0e83b45361c0047d8913e73..3c2446915862b778d360e4530ad29281022b9df6 100644 (file)
@@ -5,7 +5,7 @@ use warnings;
 
 =head1 NAME
 
-LaTeX::TikZ::Point - Interface role for what LaTeX::TikZ consider as 2D points.
+LaTeX::TikZ::Point - Internal representation of what LaTeX::TikZ consider as 2D points.
 
 =head1 VERSION
 
@@ -15,13 +15,42 @@ Version 0.01
 
 our $VERSION = '0.01';
 
-use Any::Moose 'Role';
+use Any::Moose;
+use Any::Moose 'Util::TypeConstraints' => [ qw/
+ coerce
+ from
+ via
+ find_type_constraint
+ register_type_constraint
+/ ];
+
+has 'x' => (
+ is       => 'ro',
+ isa      => 'Num',
+ required => 1,
+);
+
+has 'y' => (
+ is       => 'ro',
+ isa      => 'Num',
+ required => 1,
+);
 
-requires qw(
- x
- y
+use LaTeX::TikZ::Meta::TypeConstraint::Autocoerce;
+
+register_type_constraint(
+ LaTeX::TikZ::Meta::TypeConstraint::Autocoerce->new(
+  name   => 'LaTeX::TikZ::Point::Autocoerce',
+  parent => find_type_constraint(__PACKAGE__),
+ ),
 );
 
+coerce 'LaTeX::TikZ::Point::Autocoerce'
+    => from 'LaTeX::TikZ::Point'
+    => via { $_ };
+
+__PACKAGE__->meta->make_immutable;
+
 =head1 AUTHOR
 
 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.