summaryrefslogtreecommitdiff
path: root/benchmarks/cmop/lib/Bench/Construct.pm
blob: c2903044cfa7e74678dab0a9fc16ad4ee93a65e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/perl

package Bench::Construct;
use Moose;
use Moose::Util::TypeConstraints;

has class => (
    isa => "Str",
    is  => "ro",
);

eval {
coerce ArrayRef
    => from HashRef
        => via { [ %$_ ] };
};

has args => (
    isa => "ArrayRef",
    is  => "ro",
    auto_deref => 1,
    coerce     => 1,
);

sub code {
    my $self = shift;

    my $class = $self->class;
    my @args  = $self->args;

    sub { my $obj = $class->new( @args ) }
}

__PACKAGE__;

__END__