summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2009-09-21 01:31:58 -0500
committerJesse Luehrs <doy@tozt.net>2009-09-21 01:31:58 -0500
commit92f9ce683247b58ef533d3dd1f83bbd5536dd314 (patch)
tree63d54aaa3c822ebd726f8953918d8b3b04981792
parentef9e9eeca018131c99552c07b50684148e729dca (diff)
downloadmoosex-methodtraits-92f9ce683247b58ef533d3dd1f83bbd5536dd314.tar.gz
moosex-methodtraits-92f9ce683247b58ef533d3dd1f83bbd5536dd314.zip
if we pass in a method object rather than a coderef, use its metaclass
-rw-r--r--lib/MooseX/MethodTraits.pm4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/MooseX/MethodTraits.pm b/lib/MooseX/MethodTraits.pm
index 14a7280..29214c3 100644
--- a/lib/MooseX/MethodTraits.pm
+++ b/lib/MooseX/MethodTraits.pm
@@ -1,5 +1,6 @@
package MooseX::MethodTraits;
use Moose::Exporter;
+use Scalar::Util qw(blessed);
=head1 NAME
@@ -29,8 +30,9 @@ sub _generate_method_creators {
# initializing attributes in the method traits that are applied
my ($method, $args) = $munge->(@_);
+ my $superclass = blessed($method) || $meta->method_metaclass;
my $method_metaclass = Moose::Meta::Class->create_anon_class(
- superclasses => [$meta->method_metaclass],
+ superclasses => [$superclass],
roles => $traits,
cache => 1,
);