From: Shlomi Fish Date: Sun, 23 Aug 2009 21:32:47 +0000 (+0300) Subject: Move _gld_spec to ::GLD - it's only used there. X-Git-Tag: 0.22~6 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMooseX-Getopt.git;a=commitdiff_plain;h=a20996695460dc338556f0435299555074c76c34;hp=ed3bf9a5b6a09a361b133ac12bb07775d12e4f14 Move _gld_spec to ::GLD - it's only used there. --- diff --git a/lib/MooseX/Getopt/Basic.pm b/lib/MooseX/Getopt/Basic.pm index 06ec38b..5473d04 100644 --- a/lib/MooseX/Getopt/Basic.pm +++ b/lib/MooseX/Getopt/Basic.pm @@ -135,38 +135,6 @@ sub _traditional_spec { return ( \@options, \%name_to_init_arg ); } -sub _gld_spec { - my ( $class, %params ) = @_; - - my ( @options, %name_to_init_arg ); - - my $constructor_params = $params{params}; - - foreach my $opt ( @{ $params{options} } ) { - push @options, [ - $opt->{opt_string}, - $opt->{doc} || ' ', # FIXME new GLD shouldn't need this hack - { - ( ( $opt->{required} && !exists($constructor_params->{$opt->{init_arg}}) ) ? (required => $opt->{required}) : () ), - # NOTE: - # remove this 'feature' because it didn't work - # all the time, and so is better to not bother - # since Moose will handle the defaults just - # fine anyway. - # - SL - #( exists $opt->{default} ? (default => $opt->{default}) : () ), - }, - ]; - - my $identifier = $opt->{name}; - $identifier =~ s/\W/_/g; # Getopt::Long does this to all option names - - $name_to_init_arg{$identifier} = $opt->{init_arg}; - } - - return ( \@options, \%name_to_init_arg ); -} - sub _compute_getopt_attrs { my $class = shift; grep { diff --git a/lib/MooseX/Getopt/GLD.pm b/lib/MooseX/Getopt/GLD.pm index 87b7ad9..806d738 100644 --- a/lib/MooseX/Getopt/GLD.pm +++ b/lib/MooseX/Getopt/GLD.pm @@ -20,6 +20,39 @@ around '_get_options' => sub { ); }; + +sub _gld_spec { + my ( $class, %params ) = @_; + + my ( @options, %name_to_init_arg ); + + my $constructor_params = $params{params}; + + foreach my $opt ( @{ $params{options} } ) { + push @options, [ + $opt->{opt_string}, + $opt->{doc} || ' ', # FIXME new GLD shouldn't need this hack + { + ( ( $opt->{required} && !exists($constructor_params->{$opt->{init_arg}}) ) ? (required => $opt->{required}) : () ), + # NOTE: + # remove this 'feature' because it didn't work + # all the time, and so is better to not bother + # since Moose will handle the defaults just + # fine anyway. + # - SL + #( exists $opt->{default} ? (default => $opt->{default}) : () ), + }, + ]; + + my $identifier = $opt->{name}; + $identifier =~ s/\W/_/g; # Getopt::Long does this to all option names + + $name_to_init_arg{$identifier} = $opt->{init_arg}; + } + + return ( \@options, \%name_to_init_arg ); +} + 1; __END__