From: Dave Rolsky Date: Wed, 10 Feb 2010 21:21:50 +0000 (-0600) Subject: We no longer need special logic for applying roles with class attributes to an instance. X-Git-Tag: 0.12~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1359a1b8db89c4e7849d13570a8907c10a5e7992;p=gitmo%2FMooseX-ClassAttribute.git We no longer need special logic for applying roles with class attributes to an instance. --- diff --git a/lib/MooseX/ClassAttribute.pm b/lib/MooseX/ClassAttribute.pm index 15239a7..324068e 100644 --- a/lib/MooseX/ClassAttribute.pm +++ b/lib/MooseX/ClassAttribute.pm @@ -12,7 +12,6 @@ use MooseX::ClassAttribute::Trait::Class; use MooseX::ClassAttribute::Trait::Role; use MooseX::ClassAttribute::Trait::Application::ToClass; use MooseX::ClassAttribute::Trait::Application::ToRole; -use MooseX::ClassAttribute::Trait::Application::ToInstance; Moose::Exporter->setup_import_methods( with_meta => ['class_has'] ); @@ -31,9 +30,6 @@ sub init_meta { ['MooseX::ClassAttribute::Trait::Application::ToClass'], application_to_role => ['MooseX::ClassAttribute::Trait::Application::ToRole'], - application_to_instance => [ - 'MooseX::ClassAttribute::Trait::Application::ToInstance' - ], }, ); } diff --git a/lib/MooseX/ClassAttribute/Trait/Application/ToInstance.pm b/lib/MooseX/ClassAttribute/Trait/Application/ToInstance.pm deleted file mode 100644 index 0752d27..0000000 --- a/lib/MooseX/ClassAttribute/Trait/Application/ToInstance.pm +++ /dev/null @@ -1,73 +0,0 @@ -package MooseX::ClassAttribute::Trait::Application::ToInstance; - -use strict; -use warnings; - -our $VERSION = '0.11'; - -use namespace::autoclean; -use Moose::Role; - -after apply => sub { - shift->_apply_class_attributes(@_); -}; - -sub _apply_class_attributes { - my $self = shift; - my $role = shift; - my $object = shift; - - my $class = Moose::Util::MetaRole::apply_metaclass_roles( - for => ref $object, - class_metaroles => { - class => ['MooseX::ClassAttribute::Trait::Class'], - }, - ); - - my $attr_metaclass = $class->attribute_metaclass(); - - foreach my $attribute_name ( $role->get_class_attribute_list() ) { - if ( $class->has_class_attribute($attribute_name) - && $class->get_class_attribute($attribute_name) - != $role->get_class_attribute($attribute_name) ) { - next; - } - else { - $class->add_class_attribute( - $role->get_class_attribute($attribute_name) - ->attribute_for_class($attr_metaclass) ); - } - } -} - -1; - -__END__ - -=pod - -=head1 NAME - -MooseX::ClassAttribute::Trait::Application::ToClass - A trait that supports applying class attributes to instances - -=head1 DESCRIPTION - -This trait is used to allow the application of roles containing class -attributes to object instances. - -=head1 AUTHOR - -Dave Rolsky, C<< >> - -=head1 BUGS - -See L for details. - -=head1 COPYRIGHT & LICENSE - -Copyright 2007-2010 Dave Rolsky, All Rights Reserved. - -This program is free software; you can redistribute it and/or modify -it under the same terms as Perl itself. - -=cut diff --git a/lib/MooseX/ClassAttribute/Trait/Application/ToRole.pm b/lib/MooseX/ClassAttribute/Trait/Application/ToRole.pm index 48f7e2a..9a2dde8 100644 --- a/lib/MooseX/ClassAttribute/Trait/Application/ToRole.pm +++ b/lib/MooseX/ClassAttribute/Trait/Application/ToRole.pm @@ -7,7 +7,6 @@ our $VERSION = '0.11'; use Moose::Util::MetaRole; use MooseX::ClassAttribute::Trait::Application::ToClass; -use MooseX::ClassAttribute::Trait::Application::ToInstance; use namespace::autoclean; use Moose::Role; @@ -27,9 +26,6 @@ sub _apply_class_attributes { ['MooseX::ClassAttribute::Trait::Application::ToClass'], application_to_role => ['MooseX::ClassAttribute::Trait::Application::ToRole'], - application_to_instance => [ - 'MooseX::ClassAttribute::Trait::Application::ToInstance' - ], }, );