X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;ds=sidebyside;f=lib%2FLaTeX%2FTikZ%2FSet%2FSequence.pm;h=ca7143f8e3f1bce3a26cf5664409a7489660d080;hb=e6c6fbca8df4f8df7bbce2eb98dd260ed51d9141;hp=7742435548c12366c2a0385d2f4808fc551977ad;hpb=c314e50ea7c67844e6cf5f4d1431d8bf41a39f1a;p=perl%2Fmodules%2FLaTeX-TikZ.git diff --git a/lib/LaTeX/TikZ/Set/Sequence.pm b/lib/LaTeX/TikZ/Set/Sequence.pm index 7742435..ca7143f 100644 --- a/lib/LaTeX/TikZ/Set/Sequence.pm +++ b/lib/LaTeX/TikZ/Set/Sequence.pm @@ -19,10 +19,19 @@ use List::Util (); use LaTeX::TikZ::Scope; +use LaTeX::TikZ::Interface; +use LaTeX::TikZ::Functor; + use Any::Moose; use Any::Moose 'Util::TypeConstraints' => [ qw/subtype as where find_type_constraint/ ]; +=head1 RELATIONSHIPS + +This class consumes the L and L roles, and as such implements the L and L methods. + +=cut + with qw( LaTeX::TikZ::Set LaTeX::TikZ::Set::Mutable @@ -33,9 +42,16 @@ subtype 'LaTeX::TikZ::Set::Sequence::Elements' => where { $_->does('LaTeX::TikZ::Set::Op') or $_->isa('LaTeX::TikZ::Set::Sequence') - or $_->isa('LaTeX::TikZ::Set::Mod') }; +=head1 ATTRIBUTES + +=head2 C + +The L or L objects that from the sequence. + +=cut + has '_kids' => ( is => 'ro', isa => 'Maybe[ArrayRef[LaTeX::TikZ::Set::Sequence::Elements]]', @@ -45,6 +61,12 @@ has '_kids' => ( sub kids { @{$_[0]->_kids} } +=head1 METHODS + +=head2 C + +=cut + my $ltsse_tc = find_type_constraint('LaTeX::TikZ::Set::Sequence::Elements'); sub add { @@ -57,6 +79,10 @@ sub add { $set; } +=head2 C + +=cut + sub draw { my $set = shift; @@ -65,11 +91,20 @@ sub draw { $set->kids; } -use LaTeX::TikZ::API seq => sub { - shift; +LaTeX::TikZ::Interface->register( + seq => sub { + shift; - __PACKAGE__->new(kids => \@_); -}; + __PACKAGE__->new(kids => \@_); + }, +); + +LaTeX::TikZ::Functor->default_rule( + (__PACKAGE__) => sub { + my ($functor, $set, @args) = @_; + $set->new(kids => [ map $_->$functor(@args), $set->kids ]) + } +); __PACKAGE__->meta->make_immutable;