Allow overloading on arguments to native trait methods
[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
88e88a7b 6use Params::Util ();
7
10bd99ec 8our $VERSION = '1.14';
a7821be5 9$VERSION = eval $VERSION;
10our $AUTHORITY = 'cpan:STEVAN';
11
8b9641b8 12use Moose::Role;
13
14with 'Moose::Meta::Method::Accessor::Native::Array::Writer' => {
15 -excludes => [
16 qw(
17 _maximum_arguments
18 _inline_check_arguments
19 )
20 ]
21};
a7821be5 22
23sub _maximum_arguments { 1 }
24
25sub _inline_check_arguments {
e3181911 26 my $self = shift;
27
28 return $self->_inline_throw_error(
29 q{'The argument passed to sort_in_place must be a code reference'})
88e88a7b 30 . q{ if @_ && ! Params::Util::_CODELIKE( $_[0] );};
a7821be5 31}
32
33sub _adds_members { 0 }
34
35sub _potential_value {
36 my ( $self, $slot_access ) = @_;
37
38 return
e32b7489 39 "[ \$_[0] ? sort { \$_[0]->( \$a, \$b ) } \@{ $slot_access } : sort \@{ $slot_access} ]";
a7821be5 40}
41
8b9641b8 42no Moose::Role;
43
a7821be5 441;