Can Perl Moose create multiple accessories?

So, the standard Perl naming convention is snake_case, but I'm writing a module for interacting with the REST API that uses camelCase, creating objects with a Moose framework. I would prefer objects to work with any occasion, but I can't get a few Moose-y accessories. The only thing I could think of was this:

has 'full_name' => ( is => 'rw', isa => 'Str', ); sub fullName {return shift->full_name(@_)}; 

Best way to do this with Moose built-in modules?

+4
source share
1 answer

Bah, the simple answer. I completely forgot MooseX::Aliases , which allows you to do this easily:

 has 'full_name' => ( is => 'rw', isa => 'Str', alias => 'fullName', # or alias => [qw(fullName)] for even more ); 

Not built-in Moose, as I thought, would be, but definitely enough.

+3
source

Source: https://habr.com/ru/post/1485539/


All Articles