stop using excludes within moose, since it's no longer necessary
[gitmo/Moose.git] / lib / Moose / Meta / Method / Accessor / Native / Array / sort_in_place.pm
1 package Moose::Meta::Method::Accessor::Native::Array::sort_in_place;
2
3 use strict;
4 use warnings;
5
6 use Params::Util ();
7
8 use Moose::Role;
9
10 with 'Moose::Meta::Method::Accessor::Native::Array::Writer';
11
12 sub _maximum_arguments { 1 }
13
14 sub _inline_check_arguments {
15     my $self = shift;
16
17     return (
18         'if (@_ && !Params::Util::_CODELIKE($_[0])) {',
19             $self->_inline_throw_error(
20                 '"The argument passed to sort_in_place must be a code '
21               . 'reference"',
22             ) . ';',
23         '}',
24     );
25 }
26
27 sub _adds_members { 0 }
28
29 sub _potential_value {
30     my $self = shift;
31     my ($slot_access) = @_;
32
33     return '[ $_[0] '
34              . '? sort { $_[0]->($a, $b) } @{ (' . $slot_access . ') } '
35              . ': sort @{ (' . $slot_access . ') } ]';
36 }
37
38 sub _return_value { '' }
39
40 no Moose::Role;
41
42 1;