From: Fuji, Goro Date: Wed, 22 Sep 2010 17:11:32 +0000 (+0900) Subject: Make code simple X-Git-Tag: 0.71~33 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=13f78bbc5485977c9fa0809cda34bea7481f7276;p=gitmo%2FMouse.git Make code simple --- diff --git a/lib/Mouse.pm b/lib/Mouse.pm index 66ac4c4..87fe84c 100644 --- a/lib/Mouse.pm +++ b/lib/Mouse.pm @@ -48,13 +48,8 @@ sub has { $meta->throw_error(q{Usage: has 'name' => ( key => value, ... )}) if @_ % 2; # odd number of arguments - if(ref $name){ # has [qw(foo bar)] => (...) - for (@{$name}){ - $meta->add_attribute($_ => @_); - } - } - else{ # has foo => (...) - $meta->add_attribute($name => @_); + for my $n(ref($name) ? @{$name} : $name){ + $meta->add_attribute($n => @_); } return; } diff --git a/lib/Mouse/Role.pm b/lib/Mouse/Role.pm index 90fb530..a4cb4c7 100644 --- a/lib/Mouse/Role.pm +++ b/lib/Mouse/Role.pm @@ -43,13 +43,8 @@ sub has { $meta->throw_error(q{Usage: has 'name' => ( key => value, ... )}) if @_ % 2; # odd number of arguments - if(ref $name){ # has [qw(foo bar)] => (...) - for (@{$name}){ - $meta->add_attribute($_ => @_); - } - } - else{ # has foo => (...) - $meta->add_attribute($name => @_); + for my $n(ref($name) ? @{$name} : $name){ + $meta->add_attribute($n => @_); } return; }