This software helps with the management of "hases" through a process called currying. It allows for the manipulation and organization of data related to identifying and analyzing "has" statements.
One of the most common use cases for this extension is creating a standalone "has library" module, which can then be used across multiple classes. If you only need a curried has for one class, it's possible to define a sub has_datetime { has(...) } within that class instead.
When using this module, you can further customize each curried has by specifying additional options on the import line. For example, you might use the following syntax:
use MyAttrs (
has_datetime => {
is => 'ro',
},
has_datetime => {
-as => 'needs_datetime',
required => 1,
},
);
Your "defaults" for the attribute can also be defined as a code reference. This reference will receive both the additional specializations performed when the curried attribute was imported, as well as any additional specializations used in the individual attribute. This can be incredibly powerful, as demonstrated in the t/007-smart-has.t test file.
To use MooseX::Attributes::Curried in your own code, you simply need to add it to your package and define the appropriate attributes. For example:
package MyAttrs;
use MooseX::Attributes::Curried (
has_datetime => {
isa => 'DateTime',
default => sub { DateTime->now },
},
has_rw => {
is => 'rw',
},
);
package My::Class;
use Moose;
use MyAttrs;
has_datetime 'birthday' => (
is => 'ro',
);
has_rw 'age' => (
isa => 'Int',
);
Overall, MooseX::Attributes::Curried is a highly valuable module for developers working with Perl and Moose. Its ability to simplify attribute definition and eliminate duplication can greatly improve code organization and efficiency.
Version 0.03: N/A