NAME
Fink::Base - basic parameter handling
SYNOPSIS
package My::Fink; require Fink::Base; @ISA = qw(Fink::Base);
my $obj = My::Fink->new_from_properties({ key1 => val1, ...}); my $val = $obj->param($param); $obj->set_param($param, $val);
DESCRIPTION
Basic parameter handling for fink objects.
Constructors
- new
my $obj = Fink::Base->new;
Create a new, empty fink object.
- new_from_properties
my $obj = Fink::Base->new_from_properties({ key1 => val1, ...});
Create a new fink object setting its parameters to the given hash.
Any key with a leading _ is ignored.
- initialize
$obj->initialize;
Protected method, do not call directly.
All Fink::Base constructors will call initialize() just before returning the object.
The default initialize() is empty. You may override.
Parameter queries
All keys are used case insensitively.
- param
my $value = $obj->param($param);
Returns the $value of the given $param.
- set_param
$obj->set_param($param, $value);
Sets the $param to $value. If $value is undef or '' the $param is deleted.
- param_default
my $value = $obj->param_default($param, $default_value);
Like param() but if the $param does not exist as a parameter $default_value will be used.
- param_boolean
my $value = $obj->param_boolean($param);
Interprets the value of $param as a boolean. "True", "Yes", "On" and "1" are all considered true while all other values are considered false. Returns 1 for true, 0 for false, and undef if the field is not present at all.
- has_param
my $exists = $obj->has_param($param);
Checks to see if the given $param has been set.
- params_matching
my @params = $obj->params_matching($regex); my @params = $obj->params_matching($regex, $with_case);
Returns a list of the parameters that exist for $obj that match the given pattern $regex. Each returned value is suitable for passing to the other param* methods. The string $regex is a treated as a perl regular expression (which will not be further interpolated), with the exception that it will not return parameters of which only a substring matches. In perl terms, a leading ^ and trailing $ are applied. In human terms, passing 'a.' will not return parameters such as 'apple' or 'cat'. If the optional $with_case is given and is true, matching will be done with case-sensitivity. If $with_case is false or not given, the matching will be case-insensitive (i.e., a /i modifier is applied). In either case, the values returned are in their actual case. The values are not returned in any particular order.