Class:...e::Lazy(3pm)

πŸ“¦ version 0.03, in alpine 3.24

πŸ’… 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 as Class::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