Subject: | Problems playing with MooseX::ClassAttribute |
Hi,
I noticed that the following use case will not compile:
use MooseX::Declare;
use MooseX::ClassAttribute;
class MXDeclare with MooseX::Getopt {
class_has ID => (
isa => 'Int',
is => 'ro',
default => sub { int rand 1000 },
);
has name => (
isa => 'Str',
is => 'ro',
required => 1,
);
}
However when I move the "use MooseX::ClassAttribute" into the class
definition it works:
use MooseX::Declare;
class MXDeclare with MooseX::Getopt {
use MooseX::ClassAttribute; # this works
class_has ID => (
isa => 'Int',
is => 'ro',
default => sub { int rand 1000 },
);
has name => (
isa => 'Str',
is => 'ro',
required => 1,
);
}
I realize this is not really a bug, more like a feature request as it
would not stop me from writing code wit this module. I just think it
would be nice to keep all the imports in the same place and it may well
point to something going on behind the scenes that you may or may not be
aware of.
I have attached the failing test and the example code. Thank you for a
great module!
Subject: | mxdeclare.t |
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More 'no_plan';
use_ok('MXDeclare') or exit;
Subject: | MXDeclare.pm |
use MooseX::Declare;
use MooseX::ClassAttribute;
class MXDeclare with MooseX::Getopt {
class_has ID => (
isa => 'Int',
is => 'ro',
default => sub { int rand 1000 },
);
has name => (
isa => 'Str',
is => 'ro',
required => 1,
);
}