Subclassing Badger::Class
package Your::Class; use Badger::Class uber => 'Badger::Class', constant => { UTILS => 'Your::Utils', CONSTANTS => 'Your::Constants', }, hooks => { foo => sub { ... }, bar => sub { ... }, };
Thus Spake Andy:
Badger::Class
is itself designed to be subclassable so that
you can easily define your own custom metaprogramming modules specific to
a particular application, or to implement your own fancy import hooks for
making life easy. The only thing you really need to know is that you should
use the special uber
hook instead of base
when defining a new class
module. This example defines some new values for the UTILS
and CONSTANTS
constants. These are used to tell Badger::Class
(and it's subclasses)
what modules they should delegate to when the utils
and constants
hooks
are used. In the usual case they are forwarded to Badger::Utils
and Badger::Constants
,
but in our subclass they'll be sent off to Your::Utils
and Your::Constants
instead.
We also define some extra foo
and bar
import hooks (but skip over the
internal definition for the sake of brevity).