Use dzil Authority plugin - remove $AUTHORITY from code
[gitmo/Moose.git] / lib / Moose / Meta / Method / Accessor / Native / Array / sort.pm
CommitLineData
910684ee 1package Moose::Meta::Method::Accessor::Native::Array::sort;
2
3use strict;
4use warnings;
5
88e88a7b 6use Params::Util ();
7
8b9641b8 8use Moose::Role;
9
10with 'Moose::Meta::Method::Accessor::Native::Reader' => {
11 -excludes => [
12 qw(
13 _maximum_arguments
14 _inline_check_arguments
15 )
16 ]
17};
910684ee 18
a7821be5 19sub _maximum_arguments { 1 }
910684ee 20
21sub _inline_check_arguments {
e3181911 22 my $self = shift;
23
53a4677c 24 return (
25 'if (@_ && !Params::Util::_CODELIKE($_[0])) {',
26 $self->_inline_throw_error(
27 '"The argument passed to sort must be a code reference"',
28 ) . ';',
29 '}',
30 );
910684ee 31}
32
33sub _return_value {
53a4677c 34 my $self = shift;
35 my ($slot_access) = @_;
910684ee 36
53a4677c 37 return '$_[0] '
38 . '? sort { $_[0]->($a, $b) } @{ (' . $slot_access . ') } '
39 . ': sort @{ (' . $slot_access . ') }';
910684ee 40}
41
8b9641b8 42no Moose::Role;
43
910684ee 441;