X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FLaTeX%2FTikZ%2FSet%2FLine.pm;h=819ccb9972c5ed3d9483f326ce0a718a18819786;hb=92147217516a40b35ca00c8e08939e8aa5478426;hp=238e1f7f75a73fa3ea13ad44e4e6a42ee6eff926;hpb=e8f0879ade07eed4f58cd52c0771f4e1ecc90b09;p=perl%2Fmodules%2FLaTeX-TikZ.git diff --git a/lib/LaTeX/TikZ/Set/Line.pm b/lib/LaTeX/TikZ/Set/Line.pm index 238e1f7..819ccb9 100644 --- a/lib/LaTeX/TikZ/Set/Line.pm +++ b/lib/LaTeX/TikZ/Set/Line.pm @@ -15,20 +15,26 @@ Version 0.01 our $VERSION = '0.01'; +use LaTeX::TikZ::Set::Point; + +use LaTeX::TikZ::Functor; + use Any::Moose; with 'LaTeX::TikZ::Set::Op'; has 'from' => ( is => 'ro', - does => 'LaTeX::TikZ::Point', + isa => 'LaTeX::TikZ::Set::Point', required => 1, + coerce => 1, ); has 'to' => ( is => 'ro', - does => 'LaTeX::TikZ::Point', + isa => 'LaTeX::TikZ::Set::Point', required => 1, + coerce => 1, ); sub path { @@ -37,12 +43,19 @@ sub path { $set->from->path(@_) . ' -- ' . $set->to->path(@_); } -use LaTeX::TikZ::API line => sub { +use LaTeX::TikZ::Interface line => sub { shift; __PACKAGE__->new(from => $_[0], to => $_[1]); }; +LaTeX::TikZ::Functor->default_rule( + (__PACKAGE__) => sub { + my ($functor, $set, @args) = @_; + $set->new(map { $_ => $set->$_->$functor(@args) } qw/from to/) + } +); + __PACKAGE__->meta->make_immutable; =head1 AUTHOR