From: Chris Prather Date: Thu, 30 Apr 2009 04:00:35 +0000 (-0400) Subject: swap instance of Class::MOP::subname to Sub::Name subname X-Git-Tag: 0.77~13 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9f2230e998246cc175e2d71d7a1c54dabc2e7ea6;p=gitmo%2FMoose.git swap instance of Class::MOP::subname to Sub::Name subname --- diff --git a/Makefile.PL b/Makefile.PL index ce4cb44..cf25cff 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -17,6 +17,7 @@ requires 'List::MoreUtils' => '0.12'; requires 'Sub::Exporter' => '0.972'; requires 'Task::Weaken' => '0'; requires 'Data::OptList' => '0'; +requires 'Sub::Name' => '0'; test_requires 'Test::More' => '0.77'; test_requires 'Test::Exception' => '0.21'; diff --git a/lib/Moose/Exporter.pm b/lib/Moose/Exporter.pm index d151d18..3b0e838 100644 --- a/lib/Moose/Exporter.pm +++ b/lib/Moose/Exporter.pm @@ -11,7 +11,7 @@ use Class::MOP; use List::MoreUtils qw( first_index uniq ); use Moose::Util::MetaRole; use Sub::Exporter; - +use Sub::Name qw(subname); my %EXPORT_SPEC; @@ -184,7 +184,7 @@ sub _make_wrapped_sub { my $wrapper = $self->_make_wrapper($caller, $sub, $fq_name); - my $sub = Class::MOP::subname($fq_name => $wrapper); + my $sub = subname($fq_name => $wrapper); $export_recorder->{$sub} = 1; diff --git a/lib/Moose/Meta/Role.pm b/lib/Moose/Meta/Role.pm index 5750156..dcca38f 100644 --- a/lib/Moose/Meta/Role.pm +++ b/lib/Moose/Meta/Role.pm @@ -7,6 +7,7 @@ use metaclass; use Scalar::Util 'blessed'; use Carp 'confess'; +use Sub::Name 'subname'; our $VERSION = '0.76'; $VERSION = eval $VERSION; @@ -399,7 +400,7 @@ sub add_method { my $full_method_name = ($self->name . '::' . $method_name); $self->add_package_symbol( { sigil => '&', type => 'CODE', name => $method_name }, - Class::MOP::subname($full_method_name => $body) + subname($full_method_name => $body) ); $self->update_package_cache_flag; # still valid, since we just added the method to the map, and if it was invalid before that then get_method_map updated it diff --git a/lib/Moose/Meta/TypeConstraint.pm b/lib/Moose/Meta/TypeConstraint.pm index d5217ca..e0bff2b 100644 --- a/lib/Moose/Meta/TypeConstraint.pm +++ b/lib/Moose/Meta/TypeConstraint.pm @@ -9,6 +9,7 @@ use overload '""' => sub { shift->name }, # stringify to tc name fallback => 1; use Scalar::Util qw(blessed refaddr); +use Sub::Name qw(subname); use base qw(Class::MOP::Object); @@ -234,7 +235,7 @@ sub _compile_subtype { if ( $check == $null_constraint ) { return $optimized_parent; } else { - return Class::MOP::subname($self->name, sub { + return subname($self->name, sub { return undef unless $optimized_parent->($_[0]); my (@args) = @_; local $_ = $args[0]; @@ -245,7 +246,7 @@ sub _compile_subtype { # general case, check all the constraints, from the first parent to ourselves my @checks = @parents; push @checks, $check if $check != $null_constraint; - return Class::MOP::subname($self->name => sub { + return subname($self->name => sub { my (@args) = @_; local $_ = $args[0]; foreach my $check (@checks) { @@ -261,7 +262,7 @@ sub _compile_type { return $check if $check == $null_constraint; # Item, Any - return Class::MOP::subname($self->name => sub { + return subname($self->name => sub { my (@args) = @_; local $_ = $args[0]; $check->(@args);