NAME
Marlin::XAttribute::Lvalue - Marlin attribute extension for lvalue accessors.
SYNOPSIS
package Local::Person {
use Marlin::Util -all;
use Types::Common -types;
use Marlin
name => {
required => true,
isa => Str,
':Lvalue' => true,
};
}
my $bob = Local::Person->new( name => 'Bob' );
say $bob->name; # "Bob"
$bob->name = "Robert"; # set a new value
say $bob->name; # "Robert"
DESCRIPTION
Creates an lvalue accessor for your attribute.
If your attribute doesn't have any defaults, type constraints or coercions, triggers, or anything else to slow it down, then it will be a fairly fast lvalue accessor generated by Class::XSAccessor.
Otherwise, it will be implemented in Pure Perl, and be much slower.
You can provide a specific name for your lvalue accessor:
package Local::Person {
use Marlin::Util -all;
use Types::Common -types;
use Marlin
name => {
required => true,
isa => Str,
':Lvalue' => 'moniker',
};
}
my $alice = Local::Person->new( name => "Alice" );
$alice->moniker = 'Allie'; # Lvalue accessor
say $alice->name; # Standard non-lvalue reader
If you don't provide a specific name, it will be created instead of your standard reader/accessor.
This extension makes no changes to your constructor.
BUGS
Please report any bugs to https://github.com/tobyink/p5-marlin/issues.
SEE ALSO
AUTHOR
Toby Inkster <tobyink@cpan.org>.
COPYRIGHT AND LICENCE
This software is copyright (c) 2025 by Toby Inkster.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
DISCLAIMER OF WARRANTIES
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
🐟🐟