aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Reaction/Role/Parameterized.pm
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2011-03-04 13:31:34 -0600
committerJesse Luehrs <doy@tozt.net>2011-03-04 13:31:34 -0600
commit9be81e194a68c4d49215701c65da3c5a264c6384 (patch)
treecbf4c3b967e1f948fc4e997362c5a7d7dea03856 /lib/Reaction/Role/Parameterized.pm
parent7e8cc0731f15f8c4b12f4a8f9d2da23d077c9b9c (diff)
downloadreaction-9be81e194a68c4d49215701c65da3c5a264c6384.tar.gz
reaction-9be81e194a68c4d49215701c65da3c5a264c6384.zip
fixes for the applied_attribute stuff in moose 2
Diffstat (limited to 'lib/Reaction/Role/Parameterized.pm')
-rw-r--r--lib/Reaction/Role/Parameterized.pm68
1 files changed, 68 insertions, 0 deletions
diff --git a/lib/Reaction/Role/Parameterized.pm b/lib/Reaction/Role/Parameterized.pm
new file mode 100644
index 0000000..98074cd
--- /dev/null
+++ b/lib/Reaction/Role/Parameterized.pm
@@ -0,0 +1,68 @@
+package Reaction::Role::Parameterized;
+
+use MooseX::Role::Parameterized ();
+use Reaction::ClassExporter;
+use Reaction::Class;
+use Moose::Meta::Class;
+
+use namespace::clean -except => [ qw(meta) ];
+
+override exports_for_package => sub {
+ my ($self, $package) = @_;
+ my %exports = $self->SUPER::exports_for_package($package);
+ delete $exports{class};
+ return %exports;
+};
+
+override default_base => sub { () };
+
+override exporter_for_package => sub {
+ my ($self) = @_;
+ my ($import) = Moose::Exporter->build_import_methods(
+ also => ['MooseX::Role::Parameterized'],
+ with_caller => ['role'],
+ );
+ $import;
+};
+
+override next_import => sub { };
+
+sub role (&) {
+ my $caller = shift;
+ my ($code) = @_;
+ &MooseX::Role::Parameterized::role($caller, sub {
+ my ($p, %args) = @_;
+ $args{operating_on} = Moose::Util::MetaRole::apply_metaroles(
+ for => $args{operating_on}->name,
+ role_metaroles => {
+ applied_attribute => ['Reaction::Role::Meta::Attribute'],
+ },
+ ) if Moose->VERSION >= 1.9900;
+ $code->($p, %args);
+ });
+}
+
+__PACKAGE__->meta->make_immutable;
+
+
+1;
+
+=head1 NAME
+
+Reaction::Role
+
+=head1 DESCRIPTION
+
+=head1 SEE ALSO
+
+L<Moose::Role>
+
+=head1 AUTHORS
+
+See L<Reaction::Class> for authors.
+
+=head1 LICENSE
+
+See L<Reaction::Class> for the license.
+
+=cut