stop using excludes within moose, since it's no longer necessary
[gitmo/Moose.git] / lib / Moose / Meta / Method / Accessor / Native / Array / sort.pm
1 package Moose::Meta::Method::Accessor::Native::Array::sort;
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::Reader';
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 must be a code reference"',
21             ) . ';',
22         '}',
23     );
24 }
25
26 sub _return_value {
27     my $self = shift;
28     my ($slot_access) = @_;
29
30     return '$_[0] '
31              . '? sort { $_[0]->($a, $b) } @{ (' . $slot_access . ') } '
32              . ': sort @{ (' . $slot_access . ') }';
33 }
34
35 no Moose::Role;
36
37 1;