Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the MooseX-Aliases CPAN distribution.

Report information
The Basics
Id: 66473
Status: rejected
Priority: 0/
Queue: MooseX-Aliases

People
Owner: Nobody in particular
Requestors: james [...] neodon.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.09
Fixed in: (no value)



Subject: Aliased attributes and methods do not satisfy role requirements
Let's say I have a role with the statement "requires qw( that )". I want to use the role in a class and have an attribute called 'this' with the property "alias => 'that'". I also want this alias to satisfy the 'requires' statement from the role. This doesn't work because Moose doesn't recognize aliased attributes (and possibly methods) as satisfying 'requires' statements from roles. I get an exception like this: 'MyApp::Role' requires the method 'that' to be implemented by 'MyApp' ... I have attached a script demonstrating the issue.
Subject: moosex-aliases-bug.pl
package MyApp::Role; use Moose::Role; requires qw( that ); package MyApp; use Moose; use MooseX::Aliases; with qw( MyApp::Role ); has this => ( isa => 'Str', is => 'rw', alias => 'that', );
This isn't a bug in MooseX::Aliases. Attribute definition and role application both happen at runtime, and any methods generated by an attribute aren't in place until the attribute is defined. If you need them to satisfy a role requirement, you'll need to apply the role after the attribute definition. (This is the same issue as fulfilling a role requirement with a normal attribute accessor.)
Thank you. Sorry for the silly mistake.