Test::Trap = 0
Path::Class = 0
Test::NoWarnings = 1.04
+Test::Moose = 0
[InstallGuide]
[MetaConfig]
use Getopt::Long 2.37 ();
-has ARGV => (is => 'rw', isa => 'ArrayRef', metaclass => "NoGetopt");
-has extra_argv => (is => 'rw', isa => 'ArrayRef', metaclass => "NoGetopt");
+has ARGV => (is => 'rw', isa => 'ArrayRef', traits => ['NoGetopt']);
+has extra_argv => (is => 'rw', isa => 'ArrayRef', traits => ['NoGetopt']);
sub process_argv {
my ($class, @params) = @_;
This is certainly not the prettiest way to go about this, but for
now it works for those who might need such a feature.
+=head2 Use 'traits' instead of 'metaclass'
+
+You should rarely need to explicitly set the attribute metaclass. It is much
+preferred to simply provide a trait (a role applied to the attribute
+metaclass), which allows other code to futher modify the attribute by applying
+additional roles.
+
+Therefore, you should first try to do this:
+
+ has 'foo' => (traits => ['Getopt'], cmd_flag => 'f');
+
=head2 Custom Metaclass alias
This now takes advantage of the Moose 0.19 feature to support
has 'foo' => (metaclass => 'MooseX::Getopt::Meta::Attribute::NoGetopt', ... );
+=head2 Use 'traits' instead of 'metaclass'
+
+You should rarely need to explicitly set the attribute metaclass. It is much
+preferred to simply provide a trait (a role applied to the attribute
+metaclass), which allows other code to futher modify the attribute by applying
+additional roles.
+
+Therefore, you should first try to do this:
+
+ has 'foo' => (traits => ['NoGetopt', ...], ...);
+
=head2 Custom Metaclass alias
This now takes advantage of the Moose 0.19 feature to support
use warnings;
use Test::More tests => 70;
+use Test::Moose;
use Test::NoWarnings 1.04 ':early';
BEGIN {
with 'MooseX::Getopt';
has 'data' => (
- metaclass => 'MooseX::Getopt::Meta::Attribute',
+ metaclass => 'Getopt',
is => 'ro',
isa => 'Str',
default => 'file.dat',
);
has 'horse' => (
- metaclass => 'MooseX::Getopt::Meta::Attribute',
+ traits => ['Getopt'],
is => 'ro',
isa => 'Str',
default => 'bray',
);
has '_private_stuff_cmdline' => (
- metaclass => 'MooseX::Getopt::Meta::Attribute',
+ traits => ['Getopt'],
is => 'ro',
isa => 'Int',
default => 832,
foreach my $attr_name (qw(data cow horse _private_stuff_cmdline)) {
my $attr = App->meta->get_attribute($attr_name);
isa_ok($attr, 'Moose::Meta::Attribute');
- isa_ok($attr, 'MooseX::Getopt::Meta::Attribute');
+ if ($attr_name eq 'data' or $attr_name eq 'cow')
+ {
+ isa_ok($attr, 'MooseX::Getopt::Meta::Attribute');
+ }
+ else
+ {
+ does_ok($attr, 'MooseX::Getopt::Meta::Attribute::Trait');
+ }
can_ok($attr, 'cmd_flag');
can_ok($attr, 'cmd_aliases');
}
with 'MooseX::Getopt';
has 'data' => (
- metaclass => 'Getopt',
+ traits => ['Getopt'],
is => 'ro',
isa => 'Str',
default => 'file.dat',
);
has 'cow' => (
- metaclass => 'Getopt',
+ traits => ['Getopt'],
is => 'ro',
isa => 'Str',
default => 'moo',
);
has 'horse' => (
- metaclass => 'Getopt',
+ traits => ['Getopt'],
is => 'ro',
isa => 'Str',
default => 'bray',
);
has 'private_stuff' => (
- metaclass => 'NoGetopt',
+ traits => ['NoGetopt'],
is => 'ro',
isa => 'Int',
default => 713
);
has '_private_stuff_cmdline' => (
- metaclass => 'Getopt',
+ traits => ['Getopt'],
is => 'ro',
isa => 'Int',
default => 832,
with 'MooseX::Getopt::Strict';
has 'data' => (
- metaclass => 'Getopt',
+ traits => ['Getopt'],
is => 'ro',
isa => 'Str',
default => 'file.dat',
);
has 'cow' => (
- metaclass => 'Getopt',
+ traits => ['Getopt'],
is => 'ro',
isa => 'Str',
default => 'moo',
with 'MooseX::Getopt';
has 'nproc' => (
- metaclass => 'Getopt',
+ traits => ['Getopt'],
is => 'ro',
isa => 'Int',
default => sub { 1 },
use warnings;
use Test::More tests => 70;
+use Test::Moose;
use Test::NoWarnings 1.04 ':early';
BEGIN {
with 'MooseX::Getopt::Basic';
has 'data' => (
- metaclass => 'MooseX::Getopt::Meta::Attribute',
+ traits => ['Getopt'],
is => 'ro',
isa => 'Str',
default => 'file.dat',
);
has 'cow' => (
- metaclass => 'Getopt',
+ traits => ['Getopt'],
is => 'ro',
isa => 'Str',
default => 'moo',
);
has 'horse' => (
- metaclass => 'MooseX::Getopt::Meta::Attribute',
+ traits => ['Getopt'],
is => 'ro',
isa => 'Str',
default => 'bray',
);
has '_private_stuff_cmdline' => (
- metaclass => 'MooseX::Getopt::Meta::Attribute',
+ traits => ['Getopt'],
is => 'ro',
isa => 'Int',
default => 832,
foreach my $attr_name (qw(data cow horse _private_stuff_cmdline)) {
my $attr = App->meta->get_attribute($attr_name);
isa_ok($attr, 'Moose::Meta::Attribute');
- isa_ok($attr, 'MooseX::Getopt::Meta::Attribute');
+ does_ok($attr, 'MooseX::Getopt::Meta::Attribute::Trait');
can_ok($attr, 'cmd_flag');
can_ok($attr, 'cmd_aliases');
}
with 'MooseX::Getopt::GLD' => { getopt_conf => [ 'pass_through' ] };
has 'foo' => (
- metaclass => 'Getopt',
is => 'ro',
isa => 'Int',
);
with 'MooseX::Getopt::GLD' => { getopt_conf => [ 'pass_through' ] };;
has 'bar' => (
- metaclass => 'Getopt',
is => 'ro',
isa => 'Int',
);