From: Dave Rolsky Date: Sun, 8 Aug 2010 09:10:49 +0000 (+0200) Subject: Tidy oddly formatted chunk of code X-Git-Tag: 1.05~12 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e42e1c474e919d733c7618cba87597acd05a6fe0;p=gitmo%2FClass-MOP.git Tidy oddly formatted chunk of code --- diff --git a/lib/Class/MOP/Method/Constructor.pm b/lib/Class/MOP/Method/Constructor.pm index df68a61..48533f9 100644 --- a/lib/Class/MOP/Method/Constructor.pm +++ b/lib/Class/MOP/Method/Constructor.pm @@ -144,28 +144,40 @@ sub _generate_slot_initializer { $default = '$instance->'.$attr->builder; } - if ( defined(my $init_arg = $attr->init_arg) ) { - return ( - 'if(exists $params->{\'' . $init_arg . '\'}){' . "\n" . - $self->_meta_instance->inline_set_slot_value( - '$instance', - $attr->name, - '$params->{\'' . $init_arg . '\'}' ) . "\n" . - '} ' . (!defined $default ? '' : 'else {' . "\n" . - $self->_meta_instance->inline_set_slot_value( + if ( defined( my $init_arg = $attr->init_arg ) ) { + return ( + 'if(exists $params->{\'' + . $init_arg . '\'}){' . "\n" + . $self->_meta_instance->inline_set_slot_value( + '$instance', + $attr->name, + '$params->{\'' . $init_arg . '\'}' + ) + . "\n" . '} ' + . ( + !defined $default ? '' : 'else {' . "\n" + . $self->_meta_instance->inline_set_slot_value( '$instance', $attr->name, - $default ) . "\n" . - '}') + $default + ) + . "\n" . '}' + ) ); - } elsif ( defined $default ) { + } + elsif ( defined $default ) { return ( $self->_meta_instance->inline_set_slot_value( '$instance', $attr->name, - $default ) . "\n" + $default + ) + . "\n" ); - } else { return '' } + } + else { + return ''; + } } sub _generate_default_value {