bump version to 1.17
[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 our $VERSION = '1.17';
9 $VERSION = eval $VERSION;
10 our $AUTHORITY = 'cpan:STEVAN';
11
12 use Moose::Role;
13
14 with 'Moose::Meta::Method::Accessor::Native::Reader' => {
15     -excludes => [
16         qw(
17             _maximum_arguments
18             _inline_check_arguments
19             )
20     ]
21 };
22
23 sub _maximum_arguments { 1 }
24
25 sub _inline_check_arguments {
26     my $self = shift;
27
28     return $self->_inline_throw_error(
29         q{'The argument passed to sort must be a code reference'})
30         . q{ if @_ && ! Params::Util::_CODELIKE( $_[0] );};
31 }
32
33 sub _return_value {
34     my $self        = shift;
35     my $slot_access = shift;
36
37     return
38         "\$_[0] ? sort { \$_[0]->( \$a, \$b ) } \@{ ($slot_access) } : sort \@{ ($slot_access) }";
39 }
40
41 no Moose::Role;
42
43 1;