From: Dave Rolsky Date: Thu, 1 Sep 2011 15:18:44 +0000 (-0500) Subject: Remove Moose::Meta::Object::Trait X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=24aaf6394f1aee5d963675226dc60d8e50fc4467;p=gitmo%2FMoose.git Remove Moose::Meta::Object::Trait Moved its code up to Class::MOP::Object Fixed a few tests that used Class::MOP::Instance without first loading Class::MOP --- diff --git a/lib/Class/MOP/Object.pm b/lib/Class/MOP/Object.pm index 9a0cdf7..40133dc 100644 --- a/lib/Class/MOP/Object.pm +++ b/lib/Class/MOP/Object.pm @@ -5,6 +5,7 @@ use strict; use warnings; use Carp qw(confess); +use Moose::Util; use Scalar::Util 'blessed'; # introspection @@ -73,7 +74,8 @@ sub _get_compatible_metaclass { my $self = shift; my ($other_name) = @_; - return $self->_get_compatible_metaclass_by_subclassing($other_name); + return $self->_get_compatible_metaclass_by_subclassing($other_name) + || $self->_get_compatible_metaclass_by_role_reconciliation(@_); } sub _get_compatible_metaclass_by_subclassing { @@ -91,6 +93,20 @@ sub _get_compatible_metaclass_by_subclassing { return; } +sub _get_compatible_metaclass_by_role_reconciliation { + my $self = shift; + my ($other_name) = @_; + my $meta_name = blessed($self) ? $self->_real_ref_name : $self; + + return unless Moose::Util::_classes_differ_by_roles_only( + $meta_name, $other_name + ); + + return Moose::Util::_reconcile_roles_for_metaclass( + $meta_name, $other_name + ); +} + 1; # ABSTRACT: Base class for metaclasses diff --git a/lib/Moose/Error/Default.pm b/lib/Moose/Error/Default.pm index b3c2f87..88ea359 100644 --- a/lib/Moose/Error/Default.pm +++ b/lib/Moose/Error/Default.pm @@ -4,14 +4,11 @@ use strict; use warnings; use Carp::Heavy; -use Class::MOP::MiniTrait; use Moose::Error::Util; use base 'Class::MOP::Object'; -Class::MOP::MiniTrait::apply(__PACKAGE__, 'Moose::Meta::Object::Trait'); - sub new { my ( $self, @args ) = @_; # can't use Moose::Error::Util::create_error here because that would break diff --git a/lib/Moose/Meta/Attribute.pm b/lib/Moose/Meta/Attribute.pm index e347197..baf3617 100644 --- a/lib/Moose/Meta/Attribute.pm +++ b/lib/Moose/Meta/Attribute.pm @@ -16,12 +16,9 @@ use Moose::Meta::Method::Accessor; use Moose::Meta::Method::Delegation; use Moose::Util (); use Moose::Util::TypeConstraints (); -use Class::MOP::MiniTrait; use base 'Class::MOP::Attribute', 'Moose::Meta::Mixin::AttributeCore'; -Class::MOP::MiniTrait::apply(__PACKAGE__, 'Moose::Meta::Object::Trait'); - __PACKAGE__->meta->add_attribute('traits' => ( reader => 'applied_traits', predicate => 'has_applied_traits', diff --git a/lib/Moose/Meta/Class.pm b/lib/Moose/Meta/Class.pm index 49114ef..b6fbaec 100644 --- a/lib/Moose/Meta/Class.pm +++ b/lib/Moose/Meta/Class.pm @@ -20,12 +20,9 @@ use Moose::Meta::Method::Constructor; use Moose::Meta::Method::Destructor; use Moose::Meta::Method::Meta; use Moose::Util; -use Class::MOP::MiniTrait; use base 'Class::MOP::Class'; -Class::MOP::MiniTrait::apply(__PACKAGE__, 'Moose::Meta::Object::Trait'); - __PACKAGE__->meta->add_attribute('roles' => ( reader => 'roles', default => sub { [] }, diff --git a/lib/Moose/Meta/Instance.pm b/lib/Moose/Meta/Instance.pm index 6cb50de..0296b6b 100644 --- a/lib/Moose/Meta/Instance.pm +++ b/lib/Moose/Meta/Instance.pm @@ -4,12 +4,8 @@ package Moose::Meta::Instance; use strict; use warnings; -use Class::MOP::MiniTrait; - use base "Class::MOP::Instance"; -Class::MOP::MiniTrait::apply(__PACKAGE__, 'Moose::Meta::Object::Trait'); - 1; # ABSTRACT: The Moose Instance metaclass diff --git a/lib/Moose/Meta/Method.pm b/lib/Moose/Meta/Method.pm index 74cbe8d..c6d14fc 100644 --- a/lib/Moose/Meta/Method.pm +++ b/lib/Moose/Meta/Method.pm @@ -3,12 +3,8 @@ package Moose::Meta::Method; use strict; use warnings; -use Class::MOP::MiniTrait; - use base 'Class::MOP::Method'; -Class::MOP::MiniTrait::apply(__PACKAGE__, 'Moose::Meta::Object::Trait'); - sub _error_thrower { my $self = shift; require Moose::Meta::Class; diff --git a/lib/Moose/Meta/Object/Trait.pm b/lib/Moose/Meta/Object/Trait.pm deleted file mode 100644 index ad3d752..0000000 --- a/lib/Moose/Meta/Object/Trait.pm +++ /dev/null @@ -1,44 +0,0 @@ - -package Moose::Meta::Object::Trait; - -use Scalar::Util qw(blessed); - -sub _get_compatible_metaclass { - my $orig = shift; - my $self = shift; - return $self->$orig(@_) - || $self->_get_compatible_metaclass_by_role_reconciliation(@_); -} - -sub _get_compatible_metaclass_by_role_reconciliation { - my $self = shift; - my ($other_name) = @_; - my $meta_name = blessed($self) ? $self->_real_ref_name : $self; - - return unless Moose::Util::_classes_differ_by_roles_only( - $meta_name, $other_name - ); - - return Moose::Util::_reconcile_roles_for_metaclass( - $meta_name, $other_name - ); -} - -1; - -# ABSTRACT: Some overrides for L functionality - -__END__ - -=pod - -=head1 DESCRIPTION - -This module is entirely private, you shouldn't ever need to interact with -it directly. - -=head1 BUGS - -See L for details on reporting bugs. - -=cut diff --git a/lib/Moose/Meta/Role.pm b/lib/Moose/Meta/Role.pm index 4b2d3eb..fbfac09 100644 --- a/lib/Moose/Meta/Role.pm +++ b/lib/Moose/Meta/Role.pm @@ -17,14 +17,11 @@ use Moose::Meta::Role::Method::Required; use Moose::Meta::Role::Method::Conflicting; use Moose::Meta::Method::Meta; use Moose::Util qw( ensure_all_roles ); -use Class::MOP::MiniTrait; use base 'Class::MOP::Module', 'Class::MOP::Mixin::HasAttributes', 'Class::MOP::Mixin::HasMethods'; -Class::MOP::MiniTrait::apply(__PACKAGE__, 'Moose::Meta::Object::Trait'); - ## ------------------------------------------------------------------ ## NOTE: ## I normally don't do this, but I am doing diff --git a/t/cmop/instance.t b/t/cmop/instance.t index 7fcd551..ec96f91 100644 --- a/t/cmop/instance.t +++ b/t/cmop/instance.t @@ -6,6 +6,7 @@ use Test::Fatal; use Scalar::Util qw/isweak reftype/; +use Class::MOP; use Class::MOP::Instance; can_ok( "Class::MOP::Instance", $_ ) for qw/ diff --git a/t/cmop/instance_inline.t b/t/cmop/instance_inline.t index 7100c80..43825fa 100644 --- a/t/cmop/instance_inline.t +++ b/t/cmop/instance_inline.t @@ -4,6 +4,7 @@ use warnings; use Test::More; use Test::Fatal; +use Class::MOP; use Class::MOP::Instance; my $C = 'Class::MOP::Instance';