From: Matt S Trout Date: Wed, 4 Apr 2012 04:20:23 +0000 (+0000) Subject: method modifiers for roles X-Git-Tag: v0.009_015~14 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=146fb40782587dcc52311e66cb0a75dfe4e79b16;p=gitmo%2FMoo.git method modifiers for roles --- diff --git a/Changes b/Changes index 7884efb..c7143a0 100644 --- a/Changes +++ b/Changes @@ -2,6 +2,7 @@ to be treated as Moose classes/roles. Supported so far: - Some level of attributes and methods for both classes and roles - Required methods in roles + - Method modifiers in roles (they're already applied in classes) 0.009014 - 2012-03-29 - Split Role::Tiny out into its own dist diff --git a/lib/Moo/HandleMoose.pm b/lib/Moo/HandleMoose.pm index 5d5c522..97b6c49 100644 --- a/lib/Moo/HandleMoose.pm +++ b/lib/Moo/HandleMoose.pm @@ -46,7 +46,12 @@ sub inject_real_metaclass_for { } } if ($am_role) { - $meta->add_required_methods(@{$Moo::Role::INFO{$name}{requires}}); + my $info = $Moo::Role::INFO{$name}; + $meta->add_required_methods(@{$info->{requires}}); + foreach my $modifier (@{$info->{modifiers}}) { + my ($type, @args) = @$modifier; + $meta->${\"add_${type}_method_modifier"}(@args); + } } else { foreach my $attr (@attrs) { foreach my $method (@{$attr->associated_methods}) { diff --git a/xt/moose-method-modifiers.t b/xt/moose-method-modifiers.t index 5a6b796..2d49a8b 100644 --- a/xt/moose-method-modifiers.t +++ b/xt/moose-method-modifiers.t @@ -16,7 +16,7 @@ use Moo::HandleMoose; around foo => sub { my ($orig, $self, @rest) = @_; $self->$orig(@rest); - $after_ran = 1; + $around_ran = 1; }; package Bar;