Hi,
Something like this should work

package App::Base;
use Moose;

has 'db_user' => ( isa => 'Str' , is => 'rw' );
has 'db_pass' => ( isa => 'Str' , is => 'rw' );

package App::FromCmd;
use Moose;

extends 'App::Base';
     with 'MooseX::Getopt';

has '+db_user' => ( required => 1 );
has '+db_pass' => ( required => 1 );

package App::Other;
use Moose;

extends 'App::Base';

package main;

my $other = App::Other->new; # okay
my $from_cmd = App::FromCmd->new; # fails, db_user and db_pass required

On Tue, Mar 24, 2009 at 5:07 PM, Zbigniew Lukasiak <zzb...@gmail.com> wrote:

> I am writing a library with a command line utility (this if for
> generating FormHandler forms) - it takes as a parameter a
> DBIx::Class::Schema.  Obviously for the for the command line utility I
> cannot pass the schema object itself - but instead I pass the
> connection params and the schema class name and build that schema on
> the fly.  I would like to make those additional params 'required' for
> the command line utility - but not for the library API version.  This
> sounds like a common thing - what would be the common solution here?
> Can I just change the 'required' field option in a Subclass?
>
> --
> Zbigniew Lukasiak
> http://brudnopis.blogspot.com/
> http://perlalchemy.blogspot.com/
>



-- 
Regards,
Mikhail

Reply via email to