From 510d4b7e8680eac30f55c154624e0899d91c72cb Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Tue, 25 Aug 2009 03:26:37 -0500 Subject: add a custom exporter for roles for commands --- lib/IM/Engine/Plugin/Commands/OO/Role.pm | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 lib/IM/Engine/Plugin/Commands/OO/Role.pm 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; -- cgit v1.2.3-54-g00ecf