6 ms·
> Similar in the Common Lisp object system we use :before, :after and :around methods Ditto for Moose (in Perl)... before draw => sub { shift->move( 50, 50
by draegtun 15y ago
> Similar in the Common Lisp object system we use :before, :after and :around methods
Ditto for Moose (in Perl)...
before draw => sub { shift->move( 50, 50 )};
sub draw { shift->draw_something }
after draw => sub { shift->move( -50, -50 )};
Also you can package up these method modifiers into a role which not only can be composed into a class but can also be applied just to an object...
{
package DrawRole;
use Moose::Role;
before draw => sub { shift->move( 50, 50 )};
after draw => sub { shift->move( -50, -50 )};
}
my $d = Draw->new;
DrawRole->meta->apply( $d );