Subject: | Can't declare alias in attribute modifier |
Using Moose 2.0001 and MX::Aliases 0.09, the attached code dies with this error:
Found unknown argument(s) passed to 'id' attribute constructor in 'Moose::Meta::Attribute': alias
at /opt/perl/perls/perl-5.14.0-RC1/lib/site_perl/5.14.0/darwin-
2level/Moose/Meta/Attribute.pm line 78
Putting 'use MooseX::Alias' in the parent class fixes the problem, but if you want to alias
something in code you're subclassing and don't control, that's not really an option.
Subject: | try.pl |
#! /opt/perl/bin/perl
use strict;
use warnings;
package MyBase;
use Moose;
# uncomment the following and this works
#use MooseX::Aliases;
has 'id' => (
is => 'ro' ,
required => 1,
);
package MyChild;
use Moose;
extends 'MyBase';
use MooseX::Aliases;
has '+id' => ( alias => 'name' );
package main;
my $child = MyChild->new({ name => 'test' });
print $child->name;