summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2009-08-25 03:26:37 -0500
committerJesse Luehrs <doy@tozt.net>2009-08-25 03:26:37 -0500
commit510d4b7e8680eac30f55c154624e0899d91c72cb (patch)
tree8c3350f62bf3f83e956b23e2e71f9409020c998d
parentdd21b9ecbd5c850b2569c75a2a6dd1a5eaf11440 (diff)
downloadim-engine-plugin-commands-510d4b7e8680eac30f55c154624e0899d91c72cb.tar.gz
im-engine-plugin-commands-510d4b7e8680eac30f55c154624e0899d91c72cb.zip
add a custom exporter for roles for commands
-rw-r--r--lib/IM/Engine/Plugin/Commands/OO/Role.pm31
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/IM/Engine/Plugin/Commands/OO/Role.pm b/lib/IM/Engine/Plugin/Commands/OO/Role.pm
new file mode 100644
index 0000000..674392a
--- /dev/null
+++ b/lib/IM/Engine/Plugin/Commands/OO/Role.pm
@@ -0,0 +1,31 @@
+package IM::Engine::Plugin::Commands::OO::Role;
+use Moose::Role ();
+use Moose::Exporter;
+use Moose::Util::MetaRole;
+
+# XXX: ick
+*command = \&IM::Engine::Plugin::Commands::OO::command;
+Moose::Exporter->setup_import_methods(
+ with_caller => ['command'],
+ also => ['Moose::Role'],
+);
+
+sub init_meta {
+ shift;
+ my %options = @_;
+ Moose::Role->init_meta(%options);
+ Moose::Util::MetaRole::apply_metaclass_roles(
+ for_class =>
+ $options{for_class},
+ # XXX: roles in moose don't have an attribute metaclass yet
+ #attribute_metaclass_roles =>
+ #['IM::Engine::Plugin::Commands::Trait::Attribute::Command',
+ #'IM::Engine::Plugin::Commands::Trait::Attribute::Formatted'],
+ metaclass_roles =>
+ ['IM::Engine::Plugin::Commands::Trait::Class::Command',
+ 'IM::Engine::Plugin::Commands::Trait::Class::Formatted'],
+ );
+ return Class::MOP::class_of($options{for_class});
+}
+
+1;