From: Jesse Luehrs Date: Thu, 21 Oct 2010 06:49:35 +0000 (-0500) Subject: simplify more stuff X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5efa6a46982d17e1ff642e8b97673c6618fa7e6d;p=gitmo%2FClass-MOP.git simplify more stuff --- diff --git a/lib/Class/MOP/Method/Accessor.pm b/lib/Class/MOP/Method/Accessor.pm index b4377e9..08bcbd1 100644 --- a/lib/Class/MOP/Method/Accessor.pm +++ b/lib/Class/MOP/Method/Accessor.pm @@ -135,15 +135,13 @@ sub _generate_accessor_method_inline { my $attr = $self->associated_attribute; my $code = try { - $self->_compile_code( - source => [ - 'sub {', - $attr->inline_set( '$_[0]', '$_[1]' ) - . ' if scalar(@_) == 2;', - $attr->inline_get('$_[0]') . ';', - '}', - ] - ); + $self->_compile_code([ + 'sub {', + $attr->inline_set('$_[0]', '$_[1]'), + 'if scalar(@_) == 2;', + $attr->inline_get('$_[0]') . ';', + '}', + ]); } catch { confess "Could not generate inline accessor because : $_"; @@ -157,15 +155,13 @@ sub _generate_reader_method_inline { my $attr = $self->associated_attribute; my $code = try { - $self->_compile_code( - source => [ - 'sub {', - 'confess "Cannot assign a value to a read-only accessor" ' - . 'if @_ > 1;', - $attr->inline_get('$_[0]') . ';', - '}', - ], - ); + $self->_compile_code([ + 'sub {', + 'confess "Cannot assign a value to a read-only accessor"', + 'if @_ > 1;', + $attr->inline_get('$_[0]') . ';', + '}', + ]); } catch { confess "Could not generate inline reader because : $_"; @@ -179,13 +175,11 @@ sub _generate_writer_method_inline { my $attr = $self->associated_attribute; my $code = try { - $self->_compile_code( - source => [ - 'sub {', - $attr->inline_set( '$_[0]', '$_[1]' ) . ';', - '}', - ], - ); + $self->_compile_code([ + 'sub {', + $attr->inline_set('$_[0]', '$_[1]') . ';', + '}', + ]); } catch { confess "Could not generate inline writer because : $_"; @@ -199,13 +193,11 @@ sub _generate_predicate_method_inline { my $attr = $self->associated_attribute; my $code = try { - $self->_compile_code( - source => [ - 'sub {', - $attr->inline_has('$_[0]') . ';', - '}', - ], - ); + $self->_compile_code([ + 'sub {', + $attr->inline_has('$_[0]') . ';', + '}', + ]); } catch { confess "Could not generate inline predicate because : $_"; @@ -219,13 +211,11 @@ sub _generate_clearer_method_inline { my $attr = $self->associated_attribute; my $code = try { - $self->_compile_code( - source => [ - 'sub {', - $attr->inline_clear('$_[0]') . ';', - '}', - ], - ); + $self->_compile_code([ + 'sub {', + $attr->inline_clear('$_[0]') . ';', + '}', + ]); } catch { confess "Could not generate inline clearer because : $_"; diff --git a/t/310_inline_structor.t b/t/310_inline_structor.t index 04732d2..27024ce 100644 --- a/t/310_inline_structor.t +++ b/t/310_inline_structor.t @@ -200,7 +200,7 @@ use Class::MOP; sub _inline_destructor { my $self = shift; - my $code = $self->_compile_code(source => 'sub { }'); + my $code = $self->_compile_code('sub { }'); $self->{body} = $code; }