summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordoy <doy@tozt.net>2009-01-25 16:50:13 -0500
committerdoy <doy@tozt.net>2009-01-25 16:50:13 -0500
commit90b080af6b0e42b817413e9da6484311cdae18d0 (patch)
tree80e641217ce9a64767064b9294646e5a3ad71a25
parentbce3359135b8c2622c2fa350827b31b6f8117859 (diff)
downloadbot-games-90b080af6b0e42b817413e9da6484311cdae18d0.tar.gz
bot-games-90b080af6b0e42b817413e9da6484311cdae18d0.zip
allow setting method metaclass attributes with the command installer (command foo => sub { ... }, pass_args => 0;)
-rw-r--r--lib/Bot/Games/OO.pm5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/Bot/Games/OO.pm b/lib/Bot/Games/OO.pm
index e486b68..7f60115 100644
--- a/lib/Bot/Games/OO.pm
+++ b/lib/Bot/Games/OO.pm
@@ -6,7 +6,7 @@ use Moose::Util::MetaRole;
sub command {
my $class = shift;
- my ($name, $code) = @_;
+ my ($name, $code, %args) = @_;
my $method_meta = $class->meta->get_method($name);
my $superclass = Moose::blessed($method_meta) || 'Moose::Meta::Method';
my $method_metaclass = Moose::Meta::Class->create_anon_class(
@@ -25,6 +25,9 @@ sub command {
);
$class->meta->add_method($name, $method_meta);
}
+ for my $attr (Bot::Games::Meta::Role::Command->meta->get_attribute_list) {
+ $method_meta->$attr($args{$attr}) if exists $args{$attr};
+ }
}
Moose::Exporter->setup_import_methods(