my $class = shift;
my %args = @_;
- $args{init_arg} ||= $args{name};
+ $args{init_arg} = $args{name}
+ unless exists $args{init_arg};
$args{is} ||= '';
bless \%args, $class;
my $attribute = $self->new(%args, name => $name, class => $class);
my $meta = $class->meta;
+ $meta->add_attribute($attribute);
+
# install an accessor
if ($attribute->{is} eq 'rw' || $attribute->{is} eq 'ro') {
my $accessor = $attribute->generate_accessor;
*{ $class . '::' . $name } = $accessor;
}
- $meta->add_attribute($attribute);
-
for my $method (qw/predicate clearer/) {
if (exists $attribute->{$method}) {
my $generator = "generate_$method";