use Carp 'confess';
use Devel::Caller 'caller_cv';
-use Scalar::Util 'blessed', 'refaddr';
+use Scalar::Util 'blessed', 'refaddr', 'reftype';
use Moose::Util::TypeConstraints qw( find_type_constraint class_type role_type );
use Params::Validate ();
my $instance;
$instance = shift @$args if blessed $args->[0];
- my %args = @$args;
+ my %args
+ = @$args == 1
+ && ref $args->[0]
+ && reftype( $args->[0] ) eq 'HASH' ? %{ $args->[0] } : @$args;
$args{$_} = $spec{$_}{constraint}->coerce( $args{$_} )
for grep { $spec{$_}{coerce} && exists $args{$_} } keys %spec;
my $instance;
$instance = shift @$args if blessed $args->[0];
- my %args = @$args;
+ my %args
+ = @$args == 1
+ && ref $args->[0]
+ && reftype( $args->[0] ) eq 'HASH' ? %{ $args->[0] } : @$args;
$args{$_} = $spec{$_}{constraint}->coerce( $args{$_} )
for grep { $spec{$_}{coerce} && exists $args{$_} } keys %spec;
if $should_cache;
}
- my @args = @{$args};
+ my @args
+ = @$args == 1
+ && ref $args->[0]
+ && reftype( $args->[0] ) eq 'ARRAY' ? @{ $args->[0] } : @$args;
$args[$_] = $pv_spec[$_]{constraint}->coerce( $args[$_] )
for grep { $pv_spec[$_] && $pv_spec[$_]{coerce} } 0 .. $#args;