--- On Wed, 9/24/08, Christopher Brown <[EMAIL PROTECTED]> wrote:
> From: Christopher Brown <[EMAIL PROTECTED]>
> Subject: Moose::Meta::Role::rename_attribute
> To: moose@perl.org
> Date: Wednesday, September 24, 2008, 8:50 PM
> Hi All,
>
> Decided to ask this one of the list rather than #Moose.
>
> Is there / should there be a
> *Moose::Meta::Role->rename_attribute* method?
> It is easy to change the guts of an attribute using the
> *has "+" *syntax,
> but I have not found an official way to change the name of
> an attribute. I
> am wondering if Moose::Meta::Role should contain a
> rename_attribute method
> that does something like the following:
>
> my ( $self, $old_name, $new_name ) = @_ ;
>
> my $attr = $self->meta->get_attribute(
> $old_name );
> $self->add_attribute( $new_name, $attr );
> $self->remove_attribute( $old_name );
>
> Thoughts,
>
> Chris
Chris,
To be honest I don't think this should be a function of Role, since in my mind
I see a Role as being something that defines a package of behavior, and it
really should not be mucking about with the attributes or methods of a class
that consumes it, unless via one of the clearly established means, such as the
advice modifiers around, before, etc., and in which case any so modified
methods should required.
So I think that doing this could well be improper separation of concerns. I
guess something like this could have some use as a utility class.
--John Napiorkowski