All of the non-mutating array helpers are now inlined.
[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 our $VERSION = '1.13';
7 $VERSION = eval $VERSION;
8 our $AUTHORITY = 'cpan:STEVAN';
9
10 use base 'Moose::Meta::Method::Accessor::Native::Array::Reader';
11
12 sub _inline_process_arguments {
13     return 'my $func = shift if @_;';
14 }
15
16 sub _inline_check_arguments {
17     return
18         q{die 'Argument must be a code reference' if $func && ( ref $func || q{} ) ne 'CODE';};
19 }
20
21 sub _return_value {
22     my $self        = shift;
23     my $slot_access = shift;
24
25     return
26         "\$func ? sort { \$func->( \$a, \$b ) } \@{ ${slot_access} } : sort \@{ $slot_access }";
27 }
28
29 1;