From 792c4b154027bf1319e32bfd582df359c409414a Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Fri, 7 May 2010 06:36:18 -0500 Subject: allow applying to classes other than the direct caller --- lib/MooseX/Attribute/Shorthand.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/MooseX/Attribute/Shorthand.pm b/lib/MooseX/Attribute/Shorthand.pm index a5821c7..49faa7f 100644 --- a/lib/MooseX/Attribute/Shorthand.pm +++ b/lib/MooseX/Attribute/Shorthand.pm @@ -19,8 +19,8 @@ MooseX::Attribute::Shorthand - sub import { my $package = shift; - my $caller = caller; my %custom_options = @_; + my $for_class = delete($custom_options{'-for_class'}) || caller; my $role = Moose::Meta::Role->create_anon_role(cache => 1); for my $option (keys %custom_options) { my $meta_options = delete $custom_options{$option}{'-meta_attr_options'}; @@ -59,7 +59,7 @@ sub import { $class->$orig($name, $options); }); Moose::Util::MetaRole::apply_metaroles( - for => $caller, + for => $for_class, class_metaroles => { attribute => [$role->name], }, -- cgit v1.2.3