X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FLaTeX%2FTikZ%2FFunctor.pm;h=eaf13cabed4a9b35bc7eb778cbc7977e8624ce47;hb=f0b56a8644ce9573f173c6b477e254f0f42401d0;hp=7e64142f1402b9d5a3b7cc13df143fe8f313deb5;hpb=594156dad44851e8a31499dfb83b9c6f089abdd4;p=perl%2Fmodules%2FLaTeX-TikZ.git diff --git a/lib/LaTeX/TikZ/Functor.pm b/lib/LaTeX/TikZ/Functor.pm index 7e64142..eaf13ca 100644 --- a/lib/LaTeX/TikZ/Functor.pm +++ b/lib/LaTeX/TikZ/Functor.pm @@ -18,6 +18,7 @@ our $VERSION = '0.01'; =head1 DESCRIPTION A functor takes a L tree and clones it according to certain rules. +Rules can apply not only to L objects, but also to the L objects they contain. =cut @@ -122,29 +123,6 @@ BEGIN { =head1 METHODS -=head2 C<< default_rule $spec => $handler >> - -Adds to all subsequently created functors a default rule for the class or role C<$spec>. - -An exception is thrown if there is already a default rule for C<$spec> ; otherwise, the new rule is appended to the current list of rules. -But if C<$spec> begins with C<'+'>, the rule will replace I default rules that apply to subclasses or subroles of C<$spec> (including C<$spec> itself). - -Returns true if and only if an existent rule was replaced. - -=cut - -sub default_rule { - shift; - - my $rule = $validate_rule->(@_); - - $insert_rule->( - $rule, - $rule->[4] ? \@default_set_rules : \@default_mod_rules, - 0, - ); -} - =head2 C<< new rules => [ $spec1 => $handler1, $spec2 => $handler2, ... ] >> Creates a new functor object that will use both the default and these user-specified rules. @@ -260,6 +238,29 @@ LaTeX::TikZ::Interface->register( }, ); +=head2 C<< default_rule $spec => $handler >> + +Adds to all subsequently created functors a default rule for the class or role C<$spec>. + +An exception is thrown if there is already a default rule for C<$spec> ; otherwise, the new rule is appended to the current list of rules. +But if C<$spec> begins with C<'+'>, the rule will replace I default rules that apply to subclasses or subroles of C<$spec> (including C<$spec> itself). + +Returns true if and only if an existent rule was replaced. + +=cut + +sub default_rule { + shift; + + my $rule = $validate_rule->(@_); + + $insert_rule->( + $rule, + $rule->[4] ? \@default_set_rules : \@default_mod_rules, + 0, + ); +} + =head1 SEE ALSO L.