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