Moose::Meta::Class::does_role already does this. (doy)
* Moose::Object now has stubs for BUILD and DEMOLISH, so they can be safely
wrapped in roles without needing to provide your own stubs. (doy)
+ * Moose::Util::add_method_modifier (and subsequently the sugar functions Moose::before,
+ Moose::after, and Moose::around) can now accept arrayrefs, with the same
+ behavior as lists. Types other than arrayref and regexp result in an error.
0.94 Mon, Jan 18, 2010
it documented here, or think we missed an important feature, please
send us a patch.
+=head1 0.95
+
+=over 4
+
+=item Moose::Util add_method_modifier behavior
+
+add_method_modifier (and subsequently the sugar functions Moose::before,
+Moose::after, and Moose::around) can now accept arrayrefs, with the same
+behavior as lists. Types other than arrayref and regexp result in an error.
+
+=back
+
=head1 0.93_01 and 0.94
=over 4
$meta->$add_modifier_method( $_->name, $code )
for @matched_methods;
}
+ elsif ($method_modifier_type eq 'ARRAY') {
+ $meta->$add_modifier_method( $_, $code ) for @{$args->[0]};
+ }
+ else {
+ $meta->throw_error(
+ sprintf(
+ "Methods passed to %s must be provided as a list, arrayref or regex, not %s",
+ $modifier_name,
+ $method_modifier_type,
+ )
+ );
+ }
}
else {
$meta->$add_modifier_method( $_, $code ) for @{$args};
--- /dev/null
+use strict;
+use warnings;
+
+use Test::More;
+use Test::Exception;
+use Moose::Util qw( add_method_modifier );
+
+my $COUNT = 0;
+{
+ package Foo;
+ use Moose;
+
+ sub foo { }
+ sub bar { }
+}
+
+lives_ok {
+ add_method_modifier('Foo', 'before', [ ['foo', 'bar'], sub { $COUNT++ } ]);
+} 'method modifier with an arrayref';
+
+dies_ok {
+ add_method_modifier('Foo', 'before', [ {'foo' => 'bar'}, sub { $COUNT++ } ]);
+} 'method modifier with a hashref';
+
+my $foo = Foo->new;
+$foo->foo;
+$foo->bar;
+is($COUNT, 2, "checking that the modifiers were installed.");
+
+
+done_testing;