From: Stevan Little Date: Mon, 7 Apr 2008 04:18:03 +0000 (+0000) Subject: refactoring even more X-Git-Tag: 0.04~38 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7591e02c3cd0117610d8e9e94f606368043ffa39;p=gitmo%2FMooseX-MetaDescription.git refactoring even more --- diff --git a/lib/MooseX/MetaDescription/Description.pm b/lib/MooseX/MetaDescription/Description.pm index 5c081d7..12ece5a 100644 --- a/lib/MooseX/MetaDescription/Description.pm +++ b/lib/MooseX/MetaDescription/Description.pm @@ -1,15 +1,12 @@ package MooseX::MetaDescription::Description; use Moose; -# need the type loaded ... -use MooseX::MetaDescription::Meta::Role::HasMetaDescription; - our $VERSION = '0.01'; our $AUTHORITY = 'cpan:STEVAN'; has 'descriptor' => ( is => 'ro', - does => 'MooseX::MetaDescription::Meta::Role::HasMetaDescription', + does => 'MooseX::MetaDescription::Meta::Trait', weak_ref => 1, required => 1, ); diff --git a/lib/MooseX/MetaDescription/Description/Attribute.pm b/lib/MooseX/MetaDescription/Description/Attribute.pm deleted file mode 100644 index 829a7a4..0000000 --- a/lib/MooseX/MetaDescription/Description/Attribute.pm +++ /dev/null @@ -1,52 +0,0 @@ -package MooseX::MetaDescription::Description::Attribute; -use Moose; - -our $VERSION = '0.01'; -our $AUTHORITY = 'cpan:STEVAN'; - -extends 'MooseX::MetaDescription::Description'; - -no Moose; 1; - -__END__ - -=pod - -=head1 NAME - -MooseX::MetaDescription::Description::Attribute - A Moosey solution to this problem - -=head1 SYNOPSIS - - use MooseX::MetaDescription::Description::Attribute; - -=head1 DESCRIPTION - -=head1 METHODS - -=over 4 - -=item B<> - -=back - -=head1 BUGS - -All complex software has bugs lurking in it, and this module is no -exception. If you find a bug please either email me, or add the bug -to cpan-RT. - -=head1 AUTHOR - -Stevan Little Estevan.little@iinteractive.comE - -=head1 COPYRIGHT AND LICENSE - -Copyright 2008 Infinity Interactive, Inc. - -L - -This library is free software; you can redistribute it and/or modify -it under the same terms as Perl itself. - -=cut diff --git a/lib/MooseX/MetaDescription/Description/Class.pm b/lib/MooseX/MetaDescription/Description/Class.pm deleted file mode 100644 index 1237ae1..0000000 --- a/lib/MooseX/MetaDescription/Description/Class.pm +++ /dev/null @@ -1,52 +0,0 @@ -package MooseX::MetaDescription::Description::Class; -use Moose; - -our $VERSION = '0.01'; -our $AUTHORITY = 'cpan:STEVAN'; - -extends 'MooseX::MetaDescription::Description'; - -no Moose; 1; - -__END__ - -=pod - -=head1 NAME - -MooseX::MetaDescription::Description::Class - A Moosey solution to this problem - -=head1 SYNOPSIS - - use MooseX::MetaDescription::Description::Class; - -=head1 DESCRIPTION - -=head1 METHODS - -=over 4 - -=item B<> - -=back - -=head1 BUGS - -All complex software has bugs lurking in it, and this module is no -exception. If you find a bug please either email me, or add the bug -to cpan-RT. - -=head1 AUTHOR - -Stevan Little Estevan.little@iinteractive.comE - -=head1 COPYRIGHT AND LICENSE - -Copyright 2008 Infinity Interactive, Inc. - -L - -This library is free software; you can redistribute it and/or modify -it under the same terms as Perl itself. - -=cut diff --git a/lib/MooseX/MetaDescription/Meta/Attribute/Trait.pm b/lib/MooseX/MetaDescription/Meta/Attribute/Trait.pm index d7ee8d5..5de2617 100644 --- a/lib/MooseX/MetaDescription/Meta/Attribute/Trait.pm +++ b/lib/MooseX/MetaDescription/Meta/Attribute/Trait.pm @@ -1,16 +1,34 @@ package MooseX::MetaDescription::Meta::Attribute::Trait; use Moose::Role; -use MooseX::MetaDescription::Description::Attribute; - our $VERSION = '0.01'; our $AUTHORITY = 'cpan:STEVAN'; -with 'MooseX::MetaDescription::Meta::Role::HasMetaDescription'; +has 'description' => ( + is => 'ro', + isa => 'HashRef', + lazy => 1, + default => sub { +{} }, +); + +has 'metadescription_classname' => ( + is => 'ro', + isa => 'Str', + default => sub { + 'MooseX::MetaDescription::Description' + } +); -has '+metadescription_classname' => ( - default => sub { - 'MooseX::MetaDescription::Description::Attribute' +has 'metadescription' => ( + is => 'ro', + isa => 'MooseX::MetaDescription::Description', + lazy => 1, + default => sub { + my $self = shift; + $self->metadescription_classname->new( + %{ $self->description }, + descriptor => $self, + ) }, ); diff --git a/lib/MooseX/MetaDescription/Meta/Class.pm b/lib/MooseX/MetaDescription/Meta/Class.pm index ee53920..eca1c93 100644 --- a/lib/MooseX/MetaDescription/Meta/Class.pm +++ b/lib/MooseX/MetaDescription/Meta/Class.pm @@ -1,19 +1,11 @@ package MooseX::MetaDescription::Meta::Class; use Moose; -use MooseX::MetaDescription::Description::Class; - our $VERSION = '0.01'; our $AUTHORITY = 'cpan:STEVAN'; extends 'Moose::Meta::Class'; - with 'MooseX::MetaDescription::Meta::Role::HasMetaDescription'; - -has '+metadescription_classname' => ( - default => sub { - 'MooseX::MetaDescription::Description::Class' - }, -); + with 'MooseX::MetaDescription::Meta::Attribute::Trait'; no Moose; 1; diff --git a/lib/MooseX/MetaDescription/Meta/Role/HasMetaDescription.pm b/lib/MooseX/MetaDescription/Meta/Role/HasMetaDescription.pm deleted file mode 100644 index a757fa0..0000000 --- a/lib/MooseX/MetaDescription/Meta/Role/HasMetaDescription.pm +++ /dev/null @@ -1,78 +0,0 @@ -package MooseX::MetaDescription::Meta::Role::HasMetaDescription; -use Moose::Role; - -our $VERSION = '0.01'; -our $AUTHORITY = 'cpan:STEVAN'; - -has 'description' => ( - is => 'ro', - isa => 'HashRef', - lazy => 1, - default => sub { +{} }, -); - -has 'metadescription_classname' => ( - is => 'ro', - isa => 'Str', -); - -has 'metadescription' => ( - is => 'ro', - isa => 'MooseX::MetaDescription::Description', - lazy => 1, - default => sub { - my $self = shift; - - # TODO: handle traits ... - - $self->metadescription_classname->new( - %{ $self->description }, - descriptor => $self, - ) - }, -); - -no Moose::Role; 1; - -__END__ - -=pod - -=head1 NAME - -MooseX::MetaDescription::Meta::Role::HasMetaDescription - A Moosey solution to this problem - -=head1 SYNOPSIS - - use MooseX::MetaDescription::Meta::Role::HasMetaDescription; - -=head1 DESCRIPTION - -=head1 METHODS - -=over 4 - -=item B<> - -=back - -=head1 BUGS - -All complex software has bugs lurking in it, and this module is no -exception. If you find a bug please either email me, or add the bug -to cpan-RT. - -=head1 AUTHOR - -Stevan Little Estevan.little@iinteractive.comE - -=head1 COPYRIGHT AND LICENSE - -Copyright 2008 Infinity Interactive, Inc. - -L - -This library is free software; you can redistribute it and/or modify -it under the same terms as Perl itself. - -=cut