From: gfx Date: Sun, 20 Sep 2009 06:58:49 +0000 (+0900) Subject: Move M::Util::(version|authority|identifier) to M::Meta::Module X-Git-Tag: 0.32~46 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=23264b5b200f08d7258efc1509846d0a161194e1;p=gitmo%2FMouse.git Move M::Util::(version|authority|identifier) to M::Meta::Module --- diff --git a/lib/Mouse/Meta/Class.pm b/lib/Mouse/Meta/Class.pm index d1bffe3..7d7d1a0 100644 --- a/lib/Mouse/Meta/Class.pm +++ b/lib/Mouse/Meta/Class.pm @@ -5,7 +5,7 @@ use warnings; use Mouse::Meta::Method::Constructor; use Mouse::Meta::Method::Destructor; use Scalar::Util qw/blessed weaken/; -use Mouse::Util qw/get_linear_isa version authority identifier get_code_info/; +use Mouse::Util qw/get_linear_isa/; use Carp 'confess'; use base qw(Mouse::Meta::Module); diff --git a/lib/Mouse/Meta/Module.pm b/lib/Mouse/Meta/Module.pm index 01d42c1..4b28c07 100755 --- a/lib/Mouse/Meta/Module.pm +++ b/lib/Mouse/Meta/Module.pm @@ -3,12 +3,25 @@ use strict; use warnings; use Scalar::Util qw/blessed weaken/; -use Mouse::Util qw/version authority identifier get_code_info/; +use Mouse::Util qw/get_code_info/; use Carp 'confess'; sub name { $_[0]->{package} } sub _method_map{ $_[0]->{methods} } + +sub version { no strict 'refs'; ${shift->name.'::VERSION'} } +sub authority { no strict 'refs'; ${shift->name.'::AUTHORITY'} } +sub identifier { + my $self = shift; + return join '-' => ( + $self->name, + ($self->version || ()), + ($self->authority || ()), + ); +} + + sub namespace{ my $name = $_[0]->{package}; no strict 'refs'; diff --git a/lib/Mouse/Util.pm b/lib/Mouse/Util.pm index ff39422..25de2ab 100644 --- a/lib/Mouse/Util.pm +++ b/lib/Mouse/Util.pm @@ -8,9 +8,6 @@ use B (); our @EXPORT_OK = qw( get_linear_isa apply_all_roles - version - authority - identifier get_code_info ); our %EXPORT_TAGS = ( @@ -63,31 +60,17 @@ BEGIN { sub get_code_info($) { my ($coderef) = @_; ref($coderef) or return; + my $cv = B::svref_2object($coderef); $cv->isa('B::CV') or return; my $gv = $cv->GV; - # bail out if GV is undefined - $gv->isa('B::SPECIAL') and return; + $gv->isa('B::GV') or return; return ($gv->STASH->NAME, $gv->NAME); } } -{ # adapted from Class::MOP::Module - - sub version { no strict 'refs'; ${shift->name.'::VERSION'} } - sub authority { no strict 'refs'; ${shift->name.'::AUTHORITY'} } - sub identifier { - my $self = shift; - join '-' => ( - $self->name, - ($self->version || ()), - ($self->authority || ()), - ); - } -} - # taken from Class/MOP.pm { my %cache; @@ -134,16 +117,14 @@ sub load_first_existing_class { my @classes = @_ or return; - foreach my $class (@classes) { + my $found; + my %exceptions; + for my $class (@classes) { unless ( _is_valid_class_name($class) ) { my $display = defined($class) ? $class : 'undef'; confess "Invalid class name ($display)"; } - } - my $found; - my %exceptions; - for my $class (@classes) { my $e = _try_load_one_class($class); if ($e) { @@ -213,7 +194,7 @@ sub apply_all_roles { else { Mouse::Meta::Role->combine_apply($meta, @roles); } - + return; } 1;