Class:...e::Lazy(3pm)
π NAME π
okay so welcome to the manual page for Class::Accessor::Lite::Lazy(3pm) β a User Contributed Perl Documentation page. The name says it all: Class::Accessor::Lite::Lazy β Class::Accessor::Lite with lazy accessor feature. That's the whole plot, bestie. π
β¨ SYNOPSIS β¨
Here's the vibe in code form β no cap, keep it exactly like this:
package MyPackage;
use Class::Accessor::Lite::Lazy (
rw_lazy => [
# implicit builder method name is "_build_foo"
qw(foo foo2),
# or specify builder explicitly
{
xxx => 'method_name',
yyy => sub {
my $self = shift;
...
},
}
],
ro_lazy => [ qw(bar) ],
# Class::Accessor::Lite functionality is also available
new => 1,
rw => [ qw(baz) ],
);
# or if you specify all attributes' builders explicitly
use Class::Accessor::Lite::Lazy (
rw_lazy => {
foo => '_build_foo',
bar => \&_build_bar,
}
);
sub _build_foo {
my $self = shift;
...
}
sub _build_bar {
my $self = shift;
...
}
π¦ DESCRIPTION π¦
Class::Accessor::Lite::Lazy provides a "lazy" accessor feature to Class::Accessor::Lite. iconic behavior incoming: if a lazy accessor gets called and no value has been set, a builder method is called to generate a value to set. It's giving "I'll make it when you actually need it" main character energy. β¨
π THE USE STATEMENT π
Just like Class::Accessor::Lite, the use statement is the way to create lazy accessors. Here's the menu:
rw_lazy => \@name_of_the_properties | \%properties_and_buildersβ creates read / write lazy accessors. Yes bestie, both read and write.ro_lazy => \@name_of_the_properties | \%properties_and_buildersβ creates read-only lazy accessors. Look but don't touch energy.new,rw,ro,woβ same asClass::Accessor::Lite. Same behavior, same crew.
πΈ FUNCTIONS πΈ
Class::Accessor::Lite::Lazy->mk_lazy_accessors(@name_of_the_properties)β creates lazy accessors in the current package. Slay.Class::Accessor::Lite::Lazy->mk_ro_lazy_accessors(@name_of_the_properties)β creates read-only lazy accessors in the current package. Obsessed.
π§ SPECIFYING BUILDERS π§
As seen in SYNOPSIS, each attribute is specified by either a string or a hashref. Lowkey simple, highkey powerful.
In the string form $attr, you specify builders implicitly β the builder method name for the attribute $attr is named _build_$attr. Cute, predictable, iykyk.
In the hashref form "{ $attr => $method_name | \&builder }", you can explicitly specify builders. Each key is the attribute name, and each value is either a string that specifies the builder method name or a coderef itself. Fr fr, you've got options. π
π AUTHOR π
motemen <motemen@gmail.com> β the icon behind this whole thing. π«Ά
π SEE ALSO π
Class::Accessor::Liteβ go look, bestie.
π LICENSE π
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Periodt. πΈ
okay that's the whole manual page, bestie! this one came from perl v5.42.2 and is dated 2023-07-03 β bye, love you, go make something iconic! πβ¨π¦
π¦ where this page comes from
- alpine 3.24: perl-class-accessor-lite-lazy-doc 0.03-r1 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms