package MooseX::Sub::Arguments::Named;
use warnings;
use strict;

use Data::Dump qw( dump );
use namespace::clean;

use base 'MooseX::Sub::Arguments::Common';

sub process_scalar_args {
    my ($class, $struct, $flags, $args) = @_;
    my %param = @$args[ $class->caller_args_start .. $#$args ];
    return map { $param{ $_->[3] } } @$struct;
}

sub process_array_arg {
    my ($class, $pos, $name, $type, $flags, $args) = @_;
    my %param = @$args[ $class->caller_args_start .. $#$args ];
    return @{ $param{ $name } };
}

sub process_hash_arg {
    my ($class, $pos, $name, $type, $flags, $args) = @_;
    my %param = @$args[ $class->caller_args_start .. $#$args ];
    return %{ $param{ $name } };
}

sub process_rest_args {
    my ($class, $type, $struct, $known, $arg_count, $flags, $args) = @_;
    my %param = @$args[ $class->caller_args_start .. $#$args ];
    return map  { ($_ => $param{ $_ }) } 
           grep { not exists $known->{ $_ } } 
           keys %param;
}

1;
