Class:...hildren(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

✨ 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 (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