[Moose-commits] r7410 - in MooseX-Role-Parameterized/trunk:
lib/MooseX/Role/Parameterized/Meta/Role t
sartak at code2.0beta.co.uk
sartak at code2.0beta.co.uk
Thu Jan 29 00:02:00 GMT 2009
Author: sartak
Date: 2009-01-28 16:01:59 -0800 (Wed, 28 Jan 2009)
New Revision: 7410
Modified:
MooseX-Role-Parameterized/trunk/lib/MooseX/Role/Parameterized/Meta/Role/Parameterizable.pm
MooseX-Role-Parameterized/trunk/t/002-role-block.t
MooseX-Role-Parameterized/trunk/t/006-requires.t
MooseX-Role-Parameterized/trunk/t/007-excludes.t
Log:
Change the API of generate_role to a hash so we can specify more
things
Modified: MooseX-Role-Parameterized/trunk/lib/MooseX/Role/Parameterized/Meta/Role/Parameterizable.pm
===================================================================
--- MooseX-Role-Parameterized/trunk/lib/MooseX/Role/Parameterized/Meta/Role/Parameterizable.pm 2009-01-28 19:07:05 UTC (rev 7409)
+++ MooseX-Role-Parameterized/trunk/lib/MooseX/Role/Parameterized/Meta/Role/Parameterizable.pm 2009-01-29 00:01:59 UTC (rev 7410)
@@ -59,10 +59,12 @@
}
sub generate_role {
- my $self = shift;
+ my $self = shift;
+ my %args = @_;
- my $parameters = @_ == 1 ? shift
- : $self->construct_parameters(@_);
+ my $parameters = blessed($args{parameters})
+ ? $args{parameters}
+ : $self->construct_parameters(%{ $args{parameters} });
confess "A role generator is required to generate roles"
unless $self->has_role_generator;
@@ -81,12 +83,16 @@
}
sub apply {
- my $self = shift;
- my $class = shift;
- my %args = @_;
+ my $self = shift;
+ my $consumer = shift;
+ my %args = @_;
- my $role = $self->generate_role(%args);
- $role->apply($class, %args);
+ my $role = $self->generate_role(
+ consumer => $consumer,
+ parameters => \%args,
+ );
+
+ $role->apply($consumer, %args);
}
sub apply_parameterizable_role {
Modified: MooseX-Role-Parameterized/trunk/t/002-role-block.t
===================================================================
--- MooseX-Role-Parameterized/trunk/t/002-role-block.t 2009-01-28 19:07:05 UTC (rev 7409)
+++ MooseX-Role-Parameterized/trunk/t/002-role-block.t 2009-01-29 00:01:59 UTC (rev 7410)
@@ -33,7 +33,9 @@
ok(MyPerson->meta->has_role_generator, "MyPerson has a role generator");
my $role = MyPerson->meta->generate_role(
- default_age => 7,
+ parameters => {
+ default_age => 7,
+ },
);
isa_ok($role, 'Moose::Meta::Role', 'generate_role created a role');
Modified: MooseX-Role-Parameterized/trunk/t/006-requires.t
===================================================================
--- MooseX-Role-Parameterized/trunk/t/006-requires.t 2009-01-28 19:07:05 UTC (rev 7409)
+++ MooseX-Role-Parameterized/trunk/t/006-requires.t 2009-01-29 00:01:59 UTC (rev 7410)
@@ -21,7 +21,11 @@
sub requires_names {
map {
- MyRole::Requires->meta->generate_role(requires => $_)->name
+ MyRole::Requires->meta->generate_role(
+ parameters => {
+ requires => $_,
+ },
+ )->name
} @_
}
Modified: MooseX-Role-Parameterized/trunk/t/007-excludes.t
===================================================================
--- MooseX-Role-Parameterized/trunk/t/007-excludes.t 2009-01-28 19:07:05 UTC (rev 7409)
+++ MooseX-Role-Parameterized/trunk/t/007-excludes.t 2009-01-29 00:01:59 UTC (rev 7410)
@@ -24,7 +24,11 @@
sub excludes_roles {
map {
- MyRole::Excluder->meta->generate_role(exclude => $_)->name
+ MyRole::Excluder->meta->generate_role(
+ parameters => {
+ exclude => $_,
+ },
+ )->name
} @_
}
More information about the Moose-commits
mailing list