X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FLaTeX%2FTikZ%2FFunctor.pm;h=2b6974e995a2854ada2a3714a5d4cf4911f99022;hb=97b908646cec259d9907cfe8ce1f66cb506086ac;hp=e302d3fbf591e31f9417555aa463f7367c5162ab;hpb=92147217516a40b35ca00c8e08939e8aa5478426;p=perl%2Fmodules%2FLaTeX-TikZ.git diff --git a/lib/LaTeX/TikZ/Functor.pm b/lib/LaTeX/TikZ/Functor.pm index e302d3f..2b6974e 100644 --- a/lib/LaTeX/TikZ/Functor.pm +++ b/lib/LaTeX/TikZ/Functor.pm @@ -15,10 +15,18 @@ Version 0.01 our $VERSION = '0.01'; +=head1 DESCRIPTION + +A functor takes a L tree and clones it according to certain rules. + +=cut + use Carp (); use Sub::Name (); +use LaTeX::TikZ::Interface; + use LaTeX::TikZ::Tools; use Any::Moose 'Util' => [ 'does_role' ]; @@ -52,7 +60,7 @@ BEGIN { } Carp::confess("Invalid handler for target $target") - unless ref $handler eq 'CODE'; + unless defined $handler and ref $handler eq 'CODE'; return [ $target, $handler, $is_set ]; }); @@ -74,6 +82,12 @@ BEGIN { }); } +=head1 METHODS + +=head2 C + +=cut + sub default_rule { shift; @@ -82,6 +96,10 @@ sub default_rule { $insert_rule->($rule, $rule->[2] ? \@default_set_rules : \@default_mod_rules); } +=head2 C<< new rules => [ $class_name => sub { ... }, ... ] >> + +=cut + sub new { my ($class, %args) = @_; @@ -134,11 +152,17 @@ MOD: }, $class; } -use LaTeX::TikZ::Interface functor => sub { - shift; +LaTeX::TikZ::Interface->register( + functor => sub { + shift; + + __PACKAGE__->new(rules => \@_); + }, +); + +=head1 SEE ALSO - __PACKAGE__->new(rules => \@_); -}; +L. =head1 AUTHOR