NAME
MooX::Keyword::Readonly - Truly readonly attributes
VERSION
Version 1.00
SYNOPSIS
package Abc;
use Moo;
use MooX::Keyword extends => '+Readonly';
readonly "array";
readonly hash => ( is => 'rw' );
...
my $abc = Abc->new({ array => [1, 2, 3], hash => { a => 1, b => 2, c => 3 }});
push @{ $abc->array }, 4; # dies as array is a readonly array
$abc->hash->{d}; # dies as hash is a readonly hash with restricted keys
If you just want radonly attributes you are probably looking at the wrong module, MooX::Readonly::Attribute works more transparently unless you are already using MooX::Keyword.
KEYWORDS
readonly
Creates a truly read only attribute.
readonly "array";
The behaviour is identical to the following Moo code.
use Const::XS qw/make_readonly/;
has array => (
is => 'ro',
coerce => sub { make_readonly($_[0]); $_[0] }
);
AUTHOR
LNATION, <email at lnation.org>
BUGS
Please report any bugs or feature requests to bug-moox-keyword-readonly at rt.cpan.org
, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=MooX-Keyword-Readonly. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc MooX::Keyword::Readonly
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
https://rt.cpan.org/NoAuth/Bugs.html?Dist=MooX-Keyword-Readonly
CPAN Ratings
Search CPAN
ACKNOWLEDGEMENTS
SEE ALSO
LICENSE AND COPYRIGHT
This software is Copyright (c) 2025 by LNATION.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)