Test2:...Prefix(3pm)

πŸ’– Test2::Harness::Settings::Prefix β€” the Test2:...Prefix(3pm) page, bestie edition πŸ’–

okay so welcome to the manual page for Test2::Harness::Settings::Prefix, which lives in the Test2:...Prefix(3pm) corner of the man page universe (Perl's User Contributed Perl Documentation section, iykyk). buckle up, this one's short and sweet but lowkey powerful ✨


🌸 NAME 🌸

Test2::Harness::Settings::Prefix β€” the abstraction of a settings category, aka a prefix. that's the whole name. iconic. short. no notes. πŸ’…


πŸŽ€ DESCRIPTION πŸŽ€

so basically, this class represents a settings category β€” which everybody just calls a prefix. that's it. that's the description. she's a category. she holds settings. main character energy fr πŸ’œ


✨ SYNOPSIS ✨

here's the vibe, copy-paste ready:

# You will rarely if ever need to construct settings yourself, usually a
# component of Test2::Harness will expose them to you.
my $settings = $thing->settings;
my $display = $settings->display;

# Once you have your prefix you can read data from it:
my $verbose = $display->verbose;

# If you dislike autoload methods you can use the 'field' method:
my $verbose = $display->field('verbose');

# You can also change values:
$display->field(verbose => 1);

# You can also use the autoloaded method as an lvalue, but this breaks on
# perls older than 5.16, so it is not used internally, and you should only
# use it if you know you will never need an older perl:
$display->verbose = 1;

okay so a few things: you're rarely if ever gonna build settings yourself β€” usually some component of Test2::Harness just hands them to you like a lil gift 🎁. then you read stuff out of your prefix, or set stuff into it. and if autoload methods give you the ick, there's always field. choose your fighter. 🫢


πŸ¦‹ METHODS πŸ¦‹

heads up bestie: any field that does not conflict with the predefined methods can be accessed via AUTOLOAD, which generates the methods as needed. so many methods, all of them conjured on demand, it's giving magic. ✨
  • $scalar_ref = $prefix->vivify_field($field_name) β€” this will force a field into existance. (yes, "existance," exactly like the original, no we will not be correcting her, she's valid πŸ’…) it returns a scalar reference to the field, and you can use that ref to set the value:
my $vref = $display->vivify_field('verbose');    # Create or find field
${$vref} = 1;                                    # set verbosity to 1
  • $bool = $prefix->check_field($field_name) β€” checks if a field is defined or not. returns a bool. simple. clean. slay. πŸ“
  • $val = $prefix->field($field_name)<br> $val = $prefix->$field_name<br> $prefix->field($field_name, $val)<br> $prefix->$field_name = $val β€” get or set the value of the specified field. this will throw an exception if the field does not exist. so do not go asking for fields that aren't real, she will yell at you 😭
Note: the lvalue form $prefix->$field_name = $val breaks on perls older then 5.16. (yes, "then," again, verbatim, being faithful to the source is the whole assignment πŸŽ€)
  • $thing = $prefix->build($class, @args) β€” this creates an instance of $class, passing along the key/value pairs from the prefix as arguments. you can also toss in extra arguments via @args. it's giving "here's my whole personality, plus a lil extra." πŸ”₯
  • $hashref = $prefix->TO_JSON() β€” this method is what lets settings get serialized into JSON. the all-caps name is not a drill, she means business. πŸ‘‘

🌈 SOURCE 🌈

the source code repository for Test2-Harness lives right here:

http://github.com/Test-More/Test2-Harness/

go. peek. it's yours. πŸ¦‹


πŸ‘‘ MAINTAINERS πŸ‘‘

  • Chad Granum <exodist@cpan.org>

πŸ’œ AUTHORS πŸ’œ

  • Chad Granum <exodist@cpan.org>

Copyright 2020 Chad Granum <exodist7@gmail.com>.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See http://dev.perl.org/licenses/


and that's the whole page, bestie!! πŸ’– huge thanks to perl v5.40.1 for hosting this lil masterpiece, timestamped 2026-05-10 β€” you ate, Test2:...Prefix(3pm), no cap. periodt. πŸŽ€βœ¨

πŸ“¦ where this page comes from