From: Shawn M Moore Date: Sun, 18 Jan 2009 02:47:00 +0000 (+0000) Subject: Use attribute_metaclass in the constructor for parameters_metaclass, and X-Git-Tag: 0.05~18 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1b0f24fa4482f5f33bcfcdaf970bb715f807e5ba;p=gitmo%2FMooseX-Role-Parameterized.git Use attribute_metaclass in the constructor for parameters_metaclass, and factor out more class names --- diff --git a/lib/MooseX/Role/Parameterized/Meta/Role/Parameterizable.pm b/lib/MooseX/Role/Parameterized/Meta/Role/Parameterizable.pm index b66d86e..c72c405 100644 --- a/lib/MooseX/Role/Parameterized/Meta/Role/Parameterizable.pm +++ b/lib/MooseX/Role/Parameterized/Meta/Role/Parameterizable.pm @@ -3,17 +3,23 @@ use Moose; extends 'Moose::Meta::Role'; use MooseX::Role::Parameterized::Meta::Role::Parameterized; +use MooseX::Role::Parameterized::Meta::Parameter; use MooseX::Role::Parameterized::Parameters; use constant parameterized_role_metaclass => 'MooseX::Role::Parameterized::Meta::Role::Parameterized'; +use constant parameter_metaclass => 'MooseX::Role::Parameterized::Meta::Parameter'; +use constant parameters_class => 'MooseX::Role::Parameterized::Parameters'; has parameters_metaclass => ( is => 'rw', isa => 'Moose::Meta::Class', lazy => 1, default => sub { - Moose::Meta::Class->create_anon_class( - superclasses => ['MooseX::Role::Parameterized::Parameters'], + my $self = shift; + + $self->parameters_class->meta->create_anon_class( + superclasses => [$self->parameters_class], + attribute_metaclass => $self->parameter_metaclass, ); }, ); diff --git a/lib/MooseX/Role/Parameterized/Parameters.pm b/lib/MooseX/Role/Parameterized/Parameters.pm index 0361d04..5846e38 100644 --- a/lib/MooseX/Role/Parameterized/Parameters.pm +++ b/lib/MooseX/Role/Parameterized/Parameters.pm @@ -1,8 +1,4 @@ package MooseX::Role::Parameterized::Parameters; -# XXX: Mister Wizard, what's the right way to declare a different attribute metaclass? -use metaclass 'Moose::Meta::Class' => ( - attribute_metaclass => 'MooseX::Role::Parameterized::Meta::Parameter', -); use Moose; __PACKAGE__->meta->make_immutable;