Class:...n::Fast(3pm)

πŸ“¦
version 0.02 Β· 2 versions
  • 0.02 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.02 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Class::Accessor::Children::Fast πŸ’–

okay bestie, so this is a 3pm perl manual page (user-contributed perl documentation, the good stuff), and it's all about Class::Accessor::Children::Fast β€” a module that does child-class + accessor generation but, like, fast. no cap.


✨ NAME ✨

Class::Accessor::Children::Fast β€” Faster, child-class/accessor generation πŸƒβ™€οΈπŸ’¨


πŸ¦‹ SYNOPSIS πŸ¦‹

so here's the glow-up, bestie. before? kinda mid. after? iconic.

BEFORE (WITHOUT THIS)

look at all this copy-paste energy 😭 three whole packages, three whole use base lines, the same thing over and over:

package MyClass::Foo;
use base qw( Class:Accessor::Fast );
__PACKAGE__->mk_ro_accessors(qw( jacob michael joshua ethan ));

package MyClass::Bar;
use base qw( Class:Accessor::Fast );
__PACKAGE__->mk_ro_accessors(qw( emily emma madison isabella ));

package MyClass::Baz;
use base qw( Class:Accessor::Fast );
__PACKAGE__->mk_ro_accessors(qw( haruka haruto miyu yuto ));

(and yes, Class:Accessor::Fast really is spelled like that in there β€” one colon, two colons, whatever, it's verbatim, don't @ me πŸ’…)

AFTER (WITH THIS)

one package. one use base. one call. ate and left no crumbs:

package MyClass;
use base qw( Class::Accessor::Children::Fast );
__PACKAGE__->mk_child_ro_accessors(
    Foo => [qw( jacob michael joshua ethan )],
    Bar => [qw( emily emma madison isabella )],
    Baz => [qw( haruka haruto miyu yuto )],
);

🌸 DESCRIPTION 🌸

this module automagically generates child classes that come with accessor/mutator methods already installed. like, they just appear. slay. ✨

and the way it does it? it inherits from Class::Accessor::Fast to make the accessors. that's the whole trick. periodt. πŸ’…


πŸ’… METHODS πŸ’…

this module hands you the following methods in addition to all the methods provided by Class::Accessor::Fast β€” so everything you already know and love is still right there, bestie.

πŸŽ€ mk_child_accessors

the vibe:

MyClass->mk_child_accessors( Foo => \@fields, ... );

this generates a child class named MyClass::Foo that has accessor/mutator methods, one for each name listed in \@fields. read + write, the full package. πŸ‘‘

πŸŽ€ mk_child_ro_accessors

the vibe:

MyClass->mk_child_ro_accessors( Bar => \@fields, ... );

this generates a child class named MyClass::Bar that has read-only accessors (ie. true accessors). look but don't touch, bestie. πŸ™ˆ

πŸŽ€ mk_child_wo_accessors

the vibe:

MyClass->mk_child_wo_accessors( Baz => \@fields, ... );

this generates a child class named MyClass::Baz that has write-only accessors (ie. mutators). you can set it, but you can't get it back. mystery main character energy. πŸ¦‹


🌈 SEE ALSO 🌈

  • Class::Accessor::Children
  • Class::Accessor::Fast

πŸ‘‘ AUTHOR πŸ‘‘

Yusuke Kawasaki <http://www.kawa.net/> β€” the icon who made this fr fr 🫢


Copyright (c) 2007 Yusuke Kawasaki. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

⭐ legal bit said with love: same terms as Perl itself, so go forth and remix responsibly.

and that's the whole page, bestie! this gem shipped as perl v5.36.0, dated 2022-12-11, under Class:...n::Fast(3pm) β€” the truncation is giving "we ran out of room in the header" but you know exactly what it means. bye pookie, go generate some children πŸ’œβœ¨πŸŽ€

πŸ“¦ where this page comes from