From: Shawn M Moore Date: Wed, 30 Jul 2008 15:31:10 +0000 (+0000) Subject: On role apply, apply all method modifiers X-Git-Tag: 0.19~224 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d99db7b6a63d3377b7854c2529a299584499080b;p=gitmo%2FMouse.git On role apply, apply all method modifiers --- diff --git a/lib/Mouse/Meta/Role.pm b/lib/Mouse/Meta/Role.pm index 79f3b7f..07203c3 100644 --- a/lib/Mouse/Meta/Role.pm +++ b/lib/Mouse/Meta/Role.pm @@ -54,6 +54,17 @@ sub apply { my $spec = $self->get_attribute($name); Mouse::Meta::Attribute->create($class, $name, %$spec); } + + for my $modifier_type (qw/before after around/) { + my $add_method = "add_${modifier_type}_method_modifier"; + my $modified = $self->{"${modifier_type}_method_modifiers"}; + + for my $method_name (keys %$modified) { + for my $code (@{ $modified->{$method_name} }) { + $class->$add_method($method_name => $code); + } + } + } } for my $modifier_type (qw/before after around/) {