Never use die in generate code when throwing an error.
[gitmo/Moose.git] / lib / Moose / Meta / Method / Accessor / Native / Array / sort_in_place.pm
CommitLineData
a7821be5 1package Moose::Meta::Method::Accessor::Native::Array::sort_in_place;
2
3use strict;
4use warnings;
5
6our $VERSION = '1.13';
7$VERSION = eval $VERSION;
8our $AUTHORITY = 'cpan:STEVAN';
9
10use base 'Moose::Meta::Method::Accessor::Native::Array::Writer';
11
12sub _maximum_arguments { 1 }
13
14sub _inline_check_arguments {
e3181911 15 my $self = shift;
16
17 return $self->_inline_throw_error(
18 q{'The argument passed to sort_in_place must be a code reference'})
19 . q{if $_[0] && ( ref $_[0] || q{} ) ne 'CODE';};
a7821be5 20}
21
22sub _adds_members { 0 }
23
24sub _potential_value {
25 my ( $self, $slot_access ) = @_;
26
27 return
28 "( \$_[0] ? sort { \$_[0]->( \$a, \$b ) } \@{ $slot_access } : sort \@{ $slot_access} )";
29}
30
311;