X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=blobdiff_plain;f=lib%2FMouse.pm;h=aac0782c667df4ff205aae814213c33330f58fa1;hp=a0ea7c3f2a9ed3597fb748b4724cbe7ef05acbff;hb=cf59b7151d2b476a74b5abd84af37770ad4cf387;hpb=431657256f423bda264c0cb76c28de72fd879b20 diff --git a/lib/Mouse.pm b/lib/Mouse.pm index a0ea7c3..aac0782 100644 --- a/lib/Mouse.pm +++ b/lib/Mouse.pm @@ -3,7 +3,7 @@ use 5.006_002; use Mouse::Exporter; # enables strict and warnings -our $VERSION = '0.40'; +our $VERSION = '0.40_09'; use Carp qw(confess); use Scalar::Util qw(blessed); @@ -30,26 +30,33 @@ Mouse::Exporter->setup_import_methods( ], ); -# XXX: for backward compatibility -our @EXPORT = qw( - extends with - has - before after around - override super - augment inner - blessed confess -); -sub extends { Mouse::Meta::Class->initialize(scalar caller)->superclasses(@_) } +sub extends { + Mouse::Meta::Class->initialize(scalar caller)->superclasses(@_); + return; +} + +sub with { + Mouse::Util::apply_all_roles(scalar(caller), @_); + return; +} sub has { my $meta = Mouse::Meta::Class->initialize(scalar caller); my $name = shift; - $meta->throw_error(q{Usage: has 'name' => ( key => value, ... )}) + $meta->throw_error(q{Usage: has 'name' => ( key => value, ... )}) if @_ % 2; # odd number of arguments - $meta->add_attribute($_ => @_) for ref($name) ? @{$name} : $name; + if(ref $name){ # has [qw(foo bar)] => (...) + for (@{$name}){ + $meta->add_attribute($_ => @_); + } + } + else{ # has foo => (...) + $meta->add_attribute($name => @_); + } + return; } sub before { @@ -60,6 +67,7 @@ sub before { for (@_) { $meta->add_before_method_modifier($_ => $code); } + return; } sub after { @@ -70,6 +78,7 @@ sub after { for (@_) { $meta->add_after_method_modifier($_ => $code); } + return; } sub around { @@ -80,10 +89,7 @@ sub around { for (@_) { $meta->add_around_method_modifier($_ => $code); } -} - -sub with { - Mouse::Util::apply_all_roles(scalar(caller), @_); + return; } our $SUPER_PACKAGE; @@ -122,6 +128,7 @@ sub inner { sub augment { #my($name, $method) = @_; Mouse::Meta::Class->initialize(scalar caller)->add_augment_method_modifier(@_); + return; } sub init_meta { @@ -150,7 +157,6 @@ sub init_meta { return $meta; } - 1; __END__ @@ -160,7 +166,7 @@ Mouse - Moose minus the antlers =head1 VERSION -This document describes Mouse version 0.40 +This document describes Mouse version 0.40_09 =head1 SYNOPSIS @@ -245,25 +251,14 @@ Sets this class' superclasses. =head2 C<< before (method|methods) => CodeRef >> -Installs a "before" method modifier. See L or -L. - -Use of this feature requires L! +Installs a "before" method modifier. See L. =head2 C<< after (method|methods) => CodeRef >> -Installs an "after" method modifier. See L or -L. - -Use of this feature requires L! - +Installs an "after" method modifier. See L. =head2 C<< around (method|methods) => CodeRef >> -Installs an "around" method modifier. See L or -L. - -Use of this feature requires L! - +Installs an "around" method modifier. See L. =head2 C<< has (name|names) => parameters >> Adds an attribute (or if passed an arrayref of names, multiple attributes) to @@ -392,7 +387,7 @@ keywords (such as L) it will break loudly instead breaking subtly. We have a public git repository: - git clone git://jules.scsys.co.uk/gitmo/Mouse.git + git clone git://git.moose.perl.org/Mouse.git =head1 DEPENDENCIES @@ -404,13 +399,17 @@ L L +L + +L + L =head1 AUTHORS -Shawn M Moore, Esartak at gmail.comE +Shawn M Moore Esartak at gmail.comE -Yuval Kogman, Enothingmuch at woobling.orgE +Yuval Kogman Enothingmuch at woobling.orgE tokuhirom