X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=blobdiff_plain;f=lib%2FMouse%2FUtil.pm;h=b51f7bc81f6ed7c00c124e0ab7e29e6bbff0033d;hp=1e8d02854a898f5dc8a1f5bfcf948157abe773a3;hb=bc71de540020f1b2b75bafd69e2021c103e1c4e3;hpb=0740bdfadd961417299539d25ee24b0c9e1938e5 diff --git a/lib/Mouse/Util.pm b/lib/Mouse/Util.pm index 1e8d028..b51f7bc 100644 --- a/lib/Mouse/Util.pm +++ b/lib/Mouse/Util.pm @@ -32,12 +32,12 @@ sub find_meta{ } sub does_role{ - my ($class_or_obj, $role) = @_; - - my $meta = Mouse::Meta::Module::class_of($class_or_obj); - - return 0 unless defined $meta; - return 1 if $meta->does_role($role); + my ($class_or_obj, $role) = @_; + + my $meta = Mouse::Meta::Module::class_of($class_or_obj); + + return 0 unless defined $meta; + return 1 if $meta->does_role($role); return 0; } @@ -87,44 +87,44 @@ BEGIN { } { # taken from Sub::Identify - sub get_code_info($) { - my ($coderef) = @_; - ref($coderef) or return; + sub get_code_info($) { + my ($coderef) = @_; + ref($coderef) or return; - my $cv = B::svref_2object($coderef); + my $cv = B::svref_2object($coderef); $cv->isa('B::CV') or return; - my $gv = $cv->GV; - $gv->isa('B::GV') or return; - - return ($gv->STASH->NAME, $gv->NAME); - } + my $gv = $cv->GV; + $gv->isa('B::GV') or return; + + return ($gv->STASH->NAME, $gv->NAME); + } } # taken from Mouse::Util (0.90) { my %cache; - sub resolve_metaclass_alias { - my ( $type, $metaclass_name, %options ) = @_; - - my $cache_key = $type . q{ } . ( $options{trait} ? '-Trait' : '' ); + sub resolve_metaclass_alias { + my ( $type, $metaclass_name, %options ) = @_; + + my $cache_key = $type . q{ } . ( $options{trait} ? '-Trait' : '' ); + + return $cache{$cache_key}{$metaclass_name} ||= do{ - return $cache{$cache_key}{$metaclass_name} ||= do{ - my $possible_full_name = join '::', 'Mouse::Meta', $type, 'Custom', ($options{trait} ? 'Trait' : ()), $metaclass_name ; - my $loaded_class = load_first_existing_class( - $possible_full_name, - $metaclass_name - ); - - $loaded_class->can('register_implementation') - ? $loaded_class->register_implementation + my $loaded_class = load_first_existing_class( + $possible_full_name, + $metaclass_name + ); + + $loaded_class->can('register_implementation') + ? $loaded_class->register_implementation : $loaded_class; - }; + }; } } @@ -265,15 +265,15 @@ sub apply_all_roles { # taken from Moose::Util 0.90 sub english_list { - return $_[0] if @_ == 1; - - my @items = sort @_; - - return "$items[0] and $items[1]" if @items == 2; - - my $tail = pop @items; - - return join q{, }, @items, "and $tail"; + return $_[0] if @_ == 1; + + my @items = sort @_; + + return "$items[0] and $items[1]" if @items == 2; + + my $tail = pop @items; + + return join q{, }, @items, "and $tail"; } sub not_supported{