Chris,
What would be the use case for this?
Also note that it is an expensive operation since it removes all the
methods and other items associated with the attribute. A simple alias
(*foo = \&bar) or delegate method (sub foo { shift->bar }) would be
much more efficient and handling most of the use cases that I can
think of.
- Stevan
On Sep 24, 2008, at 8:50 PM, Christopher Brown wrote:
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