more cleanups
[gitmo/Moose.git] / lib / Moose / Meta / Method / Accessor / Native / Array / sort_in_place.pm
CommitLineData
a7821be5 1package Moose::Meta::Method::Accessor::Native::Array::sort_in_place;
2
3use strict;
4use warnings;
5
88e88a7b 6use Params::Util ();
7
245478d5 8our $VERSION = '1.19';
a7821be5 9$VERSION = eval $VERSION;
10our $AUTHORITY = 'cpan:STEVAN';
11
8b9641b8 12use Moose::Role;
13
14with 'Moose::Meta::Method::Accessor::Native::Array::Writer' => {
15 -excludes => [
16 qw(
17 _maximum_arguments
18 _inline_check_arguments
7f5ec80d 19 _return_value
8b9641b8 20 )
21 ]
22};
a7821be5 23
24sub _maximum_arguments { 1 }
25
26sub _inline_check_arguments {
e3181911 27 my $self = shift;
28
53a4677c 29 return (
30 'if (@_ && !Params::Util::_CODELIKE($_[0])) {',
31 $self->_inline_throw_error(
32 '"The argument passed to sort_in_place must be a code '
33 . 'reference"',
34 ) . ';',
35 '}',
36 );
a7821be5 37}
38
39sub _adds_members { 0 }
40
41sub _potential_value {
53a4677c 42 my $self = shift;
43 my ($slot_access) = @_;
a7821be5 44
53a4677c 45 return '[ $_[0] '
46 . '? sort { $_[0]->($a, $b) } @{ (' . $slot_access . ') } '
47 . ': sort @{ (' . $slot_access . ') } ]';
a7821be5 48}
49
1e2c801e 50sub _return_value { '' }
7f5ec80d 51
8b9641b8 52no Moose::Role;
53
a7821be5 541;