package Aspect::Modular; use strict; use warnings; use Carp; our $VERSION = '0.10'; # creating -------------------------------------------------------------------- sub new { my $self = bless {}, shift; $self->{advice} = [$self->get_advice(@_)]; return $self; } # template methods ------------------------------------------------------------ sub get_advice {} 1; =head1 NAME Aspect::Modular - base class for reusable aspects =head1 SYNOPSIS # subclassing to create a reusable aspect package Aspect::Library::ConstructorTracer; use Aspect; use base 'Aspect::Modular'; sub get_advice { my ($self, $pointcut) = @_; after { print 'created object: '. shift->return_value. "\n" } $pointcut; } # using the new aspect package main; use Aspect; # print message when constructing new Person aspect ConstructorTracer => call 'Person::new'; =head1 DESCRIPTION All reusable aspect inherit from this class. Such aspects are created in user code, using the C sub exported by L. You call C with the class name of the reusable aspect (it must exist in the package C), and any parameters (pointcuts, class names, code to run, etc.) the specific aspect may require. The L aspect, for example, expects 2 pointcut specs for the wormhole source and target, while the L aspect expects a pointcut object, to select the subs to be profiled. You create a reusable aspect by subclassing this class, and providing one I