Skip to content

Instantly share code, notes, and snippets.

@j1n3l0
Created March 22, 2012 13:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save j1n3l0/2158368 to your computer and use it in GitHub Desktop.
Save j1n3l0/2158368 to your computer and use it in GitHub Desktop.
only accept hashrefs as arguments #moose #perl
{ 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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment