BackPA...AsHash(3pm)

πŸ“¦
version 0.42 Β· 2 versions
, in fedora 43

✨ BackPAN::Index::Role::AsHash ✨

okay bestie, so this is a page from the User Contributed Perl Documentation collection β€” it's BackPAN::Index::Role::AsHash, a Perl role (that's a 3pm manpage, iykyk) whose whole entire job is to dump an object's data out as a plain old hash. πŸ’…


🌸 NAME 🌸

BackPAN::Index::Role::AsHash β€” a role to dump object data as a hash πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

use BackPAN::Index::Role::AsHash;

sub data_methods { return qw(list of data methods) }

πŸ’– DESCRIPTION πŸ’–

It's a role. Its purpose in life? To implement <as_hash> in your result objects. That's it, that's the whole vibe. ✨

🧚 Requires

the receiving class β€” yes, you, the one who's consuming this role β€” must implement the following:

  • data_methods
my @methods = $self->data_methods;

Hands you back a list of methods that get data about the object. That's the list of stuff the role is gonna go grab. πŸ“‹

πŸ‘‘ Implements

  • as_hash
my $hash = $self->as_hash;

Produces a hash reference representing the object's data, and it builds that whole thing based on <$self->data_methods>. Every key is a method name, and every value is <$self->$method> β€” so basically it's a cute little method-name β†’ method-result situation. πŸ”₯

ngl that's genuinely the entire module. short queen, does one thing, does it well. periodt. πŸ’œ

and that's a wrap on BackPAN::Index::Role::AsHash 🫢 this page came to you courtesy of perl v5.42.0, dated 2025-07-25 β€” go forth and hash responsibly, bestie πŸ’…βœ¨

πŸ“¦ where this page comes from