X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=blobdiff_plain;f=lib%2FMouse%2FUtil.pm;h=b7ab693e809fd5b987eb029fd0f7cae3a85a6a0e;hp=785f07c577bf1e5a589db3bb71576c06853c5cef;hb=0cf6f1be4b31b31a9e0f9850e730123759ce35eb;hpb=02bf7ed13ae5d43392767a38fe71e9606f1dba76 diff --git a/lib/Mouse/Util.pm b/lib/Mouse/Util.pm index 785f07c..b7ab693 100644 --- a/lib/Mouse/Util.pm +++ b/lib/Mouse/Util.pm @@ -38,7 +38,7 @@ BEGIN{ # Because Mouse::Util is loaded first in all the Mouse sub-modules, # XS loader is placed here, not in Mouse.pm. - our $VERSION = '0.48'; + our $VERSION = '0.49'; my $xs = !(exists $INC{'Mouse/PurePerl.pm'} || $ENV{MOUSE_PUREPERL}); @@ -266,7 +266,7 @@ sub load_class { sub is_class_loaded; sub apply_all_roles { - my $applicant = Scalar::Util::blessed($_[0]) + my $consumer = Scalar::Util::blessed($_[0]) ? shift # instance : Mouse::Meta::Class->initialize(shift); # class or role name @@ -284,15 +284,15 @@ sub apply_all_roles { load_class($role_name); is_a_metarole( get_metaclass_by_name($role_name) ) - || $applicant->meta->throw_error("You can only consume roles, $role_name is not a Mouse role"); + || $consumer->meta->throw_error("You can only consume roles, $role_name is not a Mouse role"); } if ( scalar @roles == 1 ) { my ( $role_name, $params ) = @{ $roles[0] }; - get_metaclass_by_name($role_name)->apply( $applicant, defined $params ? $params : () ); + get_metaclass_by_name($role_name)->apply( $consumer, defined $params ? $params : () ); } else { - Mouse::Meta::Role->combine(@roles)->apply($applicant); + Mouse::Meta::Role->combine(@roles)->apply($consumer); } return; } @@ -310,6 +310,18 @@ sub english_list { return join q{, }, @items, "and $tail"; } +sub quoted_english_list { + return qq{'$_[0]'} if @_ == 1; + + my @items = sort @_; + + return qq{'$items[0]' and '$items[1]'} if @items == 2; + + my $tail = pop @items; + + return join q{, }, (map{ qq{'$_'} } @items), qq{and '$tail'}; +} + # common utilities sub not_supported{ @@ -332,14 +344,15 @@ sub dump :method { require 'Data/Dumper.pm'; # we don't want to create its namespace my $dd = Data::Dumper->new([$self]); - $dd->Maxdepth(defined($maxdepth) ? $maxdepth : 2); + $dd->Maxdepth(defined($maxdepth) ? $maxdepth : 3); $dd->Indent(1); return $dd->Dump(); } # general does() method -sub does :method; -*does = \&does_role; # alias +sub does :method { + goto &does_role; +} 1; __END__ @@ -350,7 +363,7 @@ Mouse::Util - Features, with or without their dependencies =head1 VERSION -This document describes Mouse version 0.48 +This document describes Mouse version 0.49 =head1 IMPLEMENTATIONS FOR