X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FLaTeX-TikZ.git;a=blobdiff_plain;f=lib%2FLaTeX%2FTikZ%2FPoint.pm;h=3c2446915862b778d360e4530ad29281022b9df6;hp=f2155e8ff75b151ef0e83b45361c0047d8913e73;hb=abde159aad84169c3dbf1aabd21c9d1bf81acf85;hpb=5adf00c880491bac3bd793a07431cf161c03643f diff --git a/lib/LaTeX/TikZ/Point.pm b/lib/LaTeX/TikZ/Point.pm index f2155e8..3c24469 100644 --- a/lib/LaTeX/TikZ/Point.pm +++ b/lib/LaTeX/TikZ/Point.pm @@ -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<< >>, L.