Subject: | Required Parameters |
Hi Michael,
Would it be possible to have a parameter to mk_constructor
that lists the required parameters to the constructor?
e.g.
package MyPackage;
use base qw/ Class::Constructor Class::Accessor /;
my @Accessors = qw(
some_attribute
);
my @Required = qw(
floogle
);
__PACKAGE__->mk_accessors(@Accessors, @Required);
__PACKAGE__->mk_constructor(
Auto_Init => \@Accessors,
Required_Params => \@Required,
);
package main;
#error: floogle is a required parameter to new
my $foo1 = MyPackage->new( some_attribute => 1 );
#everything will be all right
my $foo2 = MyPackage->new( floogle => [ qw/fie fie foe fum/ ] );
__END__
Thanks,
Clayton Scott