Moose

 view release on metacpan or  search on metacpan

benchmarks/cmop/lib/Bench/Accessor.pm  view on Meta::CPAN

#!/usr/bin/perl

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

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

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

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

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

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

sub code {
    my $self = shift;

    my $obj = $self->class->new( $self->construct );
    my @accessor_args = $self->accessor_args;
    my $accessor = $self->accessor;

    sub { $obj->$accessor( @accessor_args ) };
}

__PACKAGE__;

__END__



( run in 0.642 second using v1.01-cache-2.11-cpan-39bf76dae61 )