GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Test2::Harness::Settings::Prefix(3) User Contributed Perl Documentation Test2::Harness::Settings::Prefix(3)

Test2::Harness::Settings::Prefix - Abstraction of a settings category, aka prefix.

This class represents a settings category (prefix).

    # 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;

Note that any field that does not conflict with the predefined methods can be accessed via AUTOLOAD generating the methods as needed.
$scalar_ref = $prefix->vivify_field($field_name)
This will force a field into existance. It returns a scalar reference to the field which can be used 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)
Check if a field is defined or not.
$val = $prefix->field($field_name)
$val = $prefix->$field_name
$prefix->field($field_name, $val)
$prefix->$field_name = $val
Retrieve or set the value of the specified field. This will throw an exception if the field does not exist.

Note: The lvalue form "$prefix->$field_name = $val" breaks on perls older then 5.16.

$thing = $prefix->build($class, @args)
This will create an instance of $class passing the key/value pairs from the prefix as arguments. Additional arguments can be provided in @args.
$hashref = $prefix->TO_JSON()
This method allows settings to be serialized into JSON.

The source code repository for Test2-Harness can be found at http://github.com/Test-More/Test2-Harness/.

Chad Granum <exodist@cpan.org>

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/

2022-03-23 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.