Class:...hildren(3pm)
β¨ NAME β¨
Class::Accessor::Children β automated child-class slash accessor generation, and yes bestie that's the whole vibe π
Like, this is the Class:...hildren(3pm) page you're reading rn, from the user-contributed Perl documentation corner of the internet, and it's about to make your life SO much easier.
π¦ SYNOPSIS π¦
okay so picture this: you're out here writing a whole bunch of baby classes by hand, and it's giving exhausting. Here's the before and after, because a glow-up deserves a before and after:
π BEFORE (WITHOUT THIS)
package MyClass::Foo;
use base qw( Class:Accessor );
__PACKAGE__->mk_ro_accessors(qw( jacob michael joshua ethan ));
package MyClass::Bar;
use base qw( Class:Accessor );
__PACKAGE__->mk_ro_accessors(qw( emily emma madison isabella ));
package MyClass::Baz;
use base qw( Class:Accessor );
__PACKAGE__->mk_ro_accessors(qw( haruka haruto miyu yuto ));
π AFTER (WITH THIS)
package MyClass;
use base qw( Class::Accessor::Children );
__PACKAGE__->mk_child_ro_accessors(
Foo => [qw( jacob michael joshua ethan )],
Bar => [qw( emily emma madison isabella )],
Baz => [qw( haruka haruto miyu yuto )],
);
not me writing three entire packages when ONE could've done it π the after pic is literally main character energy.
πΈ DESCRIPTION πΈ
This module automagically generates child classes which have accessor/mutator methods. No cap, it just does it for you. β¨
This module inherits "Class::Accessor" to make accessors. So all that accessor goodness you already know and love? It's coming along for the ride, bestie. π«Ά
π METHODS π
This module provides the following methods in addition to all methods provided by "Class::Accessor". So you get everything from the parent plus these three icons below. π
π mk_child_accessors
MyClass->mk_child_accessors( Foo => \@fields, ... );
This generates a child class named "MyClass::Foo" which have accessor/mutator methods each named in "\@fields". Both directions, read AND write, the full package. π
π mk_child_ro_accessors
MyClass->mk_child_ro_accessors( Bar => \@fields, ... );
This generates a child class named "MyClass::Bar" which have read-only accessors (ie. true accessors). Look but don't touch, bestie, she's guarded. πβ¨
π§ mk_child_wo_accessors
MyClass->mk_child_wo_accessors( Baz => \@fields, ... );
This generates a child class named "MyClass::Baz" which have write-only accessor (ie. mutators). You can set it but you can't read it back, mysterious queen behaviour honestly π
π SEE ALSO π
Class::Accessor
π«Ά AUTHOR π«Ά
Yusuke Kawasaki <http://www.kawa.net/> β the icon, the legend, the moment. π
β COPYRIGHT AND LICENSE β
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. Periodt. π
okay and just so you have the receipts, this page came out of the perl v5.36.0 docs and it's dated 2022-12-11 β and it's filed under Class:...hildren(3pm) in the user contributed Perl documentation section. go forth and generate those children, bestie, slay ππ
π¦ where this page comes from
- debian bookworm: libclass-accessor-children-perl 0.02-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libclass-accessor-children-perl 0.02-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libclass-accessor-children-perl 0.02-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libclass-accessor-children-perl 0.02-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libclass-accessor-children-perl 0.02-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms