#!/usr/bin/env perl
package MooseX::Role::Parameterized;
-use strict;
-use warnings;
-use MooseX::Role::Parameterized::Meta::Role;
-
+use Moose;
use Moose::Role ();
-use Moose::Exporter;
+extends 'Moose::Exporter';
-Moose::Exporter->setup_import_methods(
- with_caller => ['parameter'],
+use MooseX::Role::Parameterized::Meta::Role;
+
+__PACKAGE__->setup_import_methods(
+ with_caller => ['parameter', 'role'],
);
sub parameter {
$caller->meta->add_parameter(@_);
}
+sub role {
+ my $caller = shift;
+ my $role_generator = shift;
+ $caller->meta->role_generator($role_generator);
+}
+
sub init_meta {
my $self = shift;
);
}
+# give role a (&) prototype
+around _make_wrapper => sub {
+ my $orig = shift;
+ my ($self, $caller, $sub, $fq_name) = @_;
+
+ if ($fq_name =~ /::role$/) {
+ return sub (&) { $sub->($caller, @_) };
+ }
+
+ return $orig->(@_);
+};
+
1;