refactor constructor inlining to reuse attribute code
[gitmo/Moose.git] / lib / Moose / Meta / Method / Accessor / Native / Reader.pm
CommitLineData
5df54980 1package Moose::Meta::Method::Accessor::Native::Reader;
2
3use strict;
4use warnings;
5
245478d5 6our $VERSION = '1.19';
5df54980 7$VERSION = eval $VERSION;
8our $AUTHORITY = 'cpan:STEVAN';
9
8b9641b8 10use Moose::Role;
11
12with 'Moose::Meta::Method::Accessor::Native';
13
14requires '_return_value';
5df54980 15
16sub _generate_method {
17 my $self = shift;
18
53a4677c 19 my $inv = '$self';
1e2c801e 20 my $slot_access = $self->_get_value($inv);
e7724627 21
53a4677c 22 return (
23 'sub {',
53a4677c 24 'my ' . $inv . ' = shift;',
25 $self->_inline_curried_arguments,
1e2c801e 26 $self->_inline_reader_core($inv, $slot_access, @_),
53a4677c 27 '}',
28 );
e7724627 29}
30
1e2c801e 31sub _inline_reader_core {
53a4677c 32 my $self = shift;
33 my ($inv, $slot_access, @extra) = @_;
34
35 return (
36 $self->_inline_check_argument_count,
37 $self->_inline_process_arguments($inv, $slot_access),
38 $self->_inline_check_arguments,
ec86bdff 39 $self->_inline_check_lazy($inv, '$type_constraint', '$type_constraint_obj'),
53a4677c 40 $self->_inline_return_value($slot_access),
41 );
5df54980 42}
43
53a4677c 44sub _inline_process_arguments { return }
e7724627 45
53a4677c 46sub _inline_check_arguments { return }
5df54980 47
8b9641b8 48no Moose::Role;
49
5df54980 501;