public
Created

only accept hashrefs as arguments #moose #perl

  • Download Gist
gistfile1.pl
Perl
1 2 3 4 5 6 7 8 9 10 11 12
{ package Foo;
use Moose;
has bar => qw( is ro required 1 );
around BUILDARGS => sub {
my ( $orig, $class, @args ) = @_;
unless ( @args == 1 && ref $args[0] eq 'HASH' ) {
die "arguments must be a hash reference";
}
return $class->$orig(@args);
};
no Moose;
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.