use MooseX::Role::Parameterized;
parameter name => (
- is => 'ro',
isa => 'Str',
required => 1,
);
C<role> block.
Parameters are declared using the L</parameter> keyword which very much
-resembles L<Moose/has>. You can use any option that L<Moose/has> accepts.
-These parameters will get their values when the consuming class (or role) uses
+resembles L<Moose/has>. You can use any option that L<Moose/has> accepts. The
+default value for the "is" option is "ro" as that's a very common case. These
+parameters will get their values when the consuming class (or role) uses
L<Moose/with>. A parameter object will be constructed with these values, and
passed to the C<role> block.
the keyword C<parameter>, but your parameters can use any options to C<has>.
parameter 'delegation' => (
- is => 'ro',
isa => 'HashRef|ArrayRef|RegexpRef',
predicate => 'has_delegation',
);
Behind the scenes, C<parameter> uses C<has> to add attributes to a parameter
-class. The arguments to C<with> are used to construct a parameter object, which
-has the attributes specified by calls to C<parameter>. The parameter object is
-then passed to...
+class (except the "is" option defaults to "ro" for convenience). The arguments
+to C<with> are used to construct a parameter object, which has the attributes
+specified by calls to C<parameter>. The parameter object is then passed to...
=head3 C<role>
can now also choose type, default value, whether it's required, B<traits>, etc.
parameter traits => (
- is => 'ro',
isa => 'ArrayRef[Str]',
default => sub { [] },
);
which attributes to dump to a file.
parameter instrument_method => (
- is => 'ro',
isa => 'Str',
required => 1,
);
states.
parameter save_intermediate => (
- is => 'ro',
isa => 'Bool',
default => 0,
);
L<Storable>. Which backend to use can be a parameter.
parameter format => (
- is => 'ro',
- isa => (enum ['Storable', 'YAML', 'JSON']),
+ isa => (enum ['Storable', 'YAML', 'JSON']),
default => 'Storable',
);