LaTeX::TikZ::Functor::Rule - An object that specifies how functors should handle a certain kind of set or mod.


Version 0.03


A rule specifies how functors (LaTeX::TikZ::Functor objects) should handle a certain kind of set or mod. A functor is basically an ordered collection of rules.



A class or role name against which set or mod candidates will be matched. It must consume either LaTeX::TikZ::Set or LaTeX::TikZ::Mod, directly or through inheritance.


The code reference executed when the rule handles a given set or mod object. It is called with the LaTeX::TikZ::Functor object as its first argument, the set/mod object as its second, and then the arguments passed to the functor itself.


True if and only if the target is a role.


True when the target does the LaTeX::TikZ::Set role, and false when it does LaTeX::TikZ::Mod.



    my $rule = LaTeX::TikZ::Functor::Rule->new(
     target  => $target,
     handler => $handler,

Constructs a new rule object with target $target and handler $handler.


    my $has_replaced = $rule->insert(
     into      => \@list,
     overwrite => $overwrite,
     replace   => $replace,

Inserts the current rule into the list of rules @list. The list is expected to be ordered, in that each rule must come after all the rules that have a target that inherits or consumes the original rule's own target.

If $replace is false, then the rule will be inserted into @list after all the rules applying to the target's subclasses/subroles and before all its superclasses/superroles ; except if there is already an existent entry for the same target, in which case it will be overwritten if $overwrite is true, or an exception will be thrown if it is false.

If $replace is true, then the rule will replace the first rule in the list that is a subclass or that consumes the role denoted by the target. All the subsequent rules in the list that inherit or consume the target will be removed.

Returns true if and only if an existent rule was replaced.



Returns true if and only if the current rule can handle the object or class/role name $obj.


LaTeX::TikZ, LaTeX::TikZ::Functor.


Vincent Pit, <perl at>,

You can contact me by mail or on (vincent).


Please report any bugs or feature requests to bug-latex-tikz at, or through the web interface at I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


You can find documentation for this module with the perldoc command.

    perldoc LaTeX::TikZ


Copyright 2010,2011,2012,2013,2014,2015 Vincent Pit, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.