diff options
author | Jesse Luehrs <doy@tozt.net> | 2010-05-07 06:36:18 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2010-05-07 06:36:18 -0500 |
commit | 792c4b154027bf1319e32bfd582df359c409414a (patch) | |
tree | dffce7b99f04bafe3c997851ae4d442c463780e8 | |
parent | 307fc5fcd99776572cd14a14c9fd50287857f13b (diff) | |
download | moosex-attribute-shorthand-792c4b154027bf1319e32bfd582df359c409414a.tar.gz moosex-attribute-shorthand-792c4b154027bf1319e32bfd582df359c409414a.zip |
allow applying to classes other than the direct caller
-rw-r--r-- | lib/MooseX/Attribute/Shorthand.pm | 4 |
1 files 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], }, |