1Test2::Harness::SettingUss:e:rPrCeofnitxr(i3b)uted PerlTDeosctu2m:e:nHtaartnieosns::Settings::Prefix(3)
2
3
4

NAME

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

DESCRIPTION

10       This class represents a settings category (prefix).
11

SYNOPSIS

13           # You will rarely if ever need to construct settings yourself, usually a
14           # component of Test2::Harness will expose them to you.
15           my $settings = $thing->settings;
16           my $display = $settings->display;
17
18           # Once you have your prefix you can read data from it:
19           my $verbose = $display->verbose;
20
21           # If you dislike autoload methods you can use the 'field' method:
22           my $verbose = $display->field('verbose');
23
24           # You can also change values:
25           $display->field(verbose => 1);
26
27           # You can also use the autoloaded method as an lvalue, but this breaks on
28           # perls older than 5.16, so it is not used internally, and you should only
29           # use it if you know you will never need an older perl:
30           $display->verbose = 1;
31

METHODS

33       Note that any field that does not conflict with the predefined methods
34       can be accessed via AUTOLOAD generating the methods as needed.
35
36       $scalar_ref = $prefix->vivify_field($field_name)
37           This will force a field into existance. It returns a scalar
38           reference to the field which can be used to set the value:
39
40               my $vref = $display->vivify_field('verbose');    # Create or find field
41               ${$vref} = 1;                                    # set verbosity to 1
42
43       $bool = $prefix->check_field($field_name)
44           Check if a field is defined or not.
45
46       $val = $prefix->field($field_name)
47       $val = $prefix->$field_name
48       $prefix->field($field_name, $val)
49       $prefix->$field_name = $val
50           Retrieve or set the value of the specified field. This will throw
51           an exception if the field does not exist.
52
53           Note: The lvalue form "$prefix->$field_name = $val" breaks on perls
54           older then 5.16.
55
56       $thing = $prefix->build($class, @args)
57           This will create an instance of $class passing the key/value pairs
58           from the prefix as arguments. Additional arguments can be provided
59           in @args.
60
61       $hashref = $prefix->TO_JSON()
62           This method allows settings to be serialized into JSON.
63

SOURCE

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

MAINTAINERS

69       Chad Granum <exodist@cpan.org>
70

AUTHORS

72       Chad Granum <exodist@cpan.org>
73
75       Copyright 2020 Chad Granum <exodist7@gmail.com>.
76
77       This program is free software; you can redistribute it and/or modify it
78       under the same terms as Perl itself.
79
80       See http://dev.perl.org/licenses/
81
82
83
84perl v5.36.1                      2023-10-04Test2::Harness::Settings::Prefix(3)
Impressum