lib/YuiRestClient/Filter.pm

NAME

YuiRestClient::Filter - manage filter for YuiRestClient

COPYRIGHT

Copyright 2021 SUSE LLC

SPDX-License-Identifier: FSFAP

AUTHORS

QE Yam <qe-yam at suse de>

SYNOPSIS

$filter = YuiRestClient::Filter->new($filter);
return $self->{widget_controller}->find($self->{filter}->get_filter());
return $self->{filter}->is_resolved();

DESCRIPTION

Overview

Every YUI object that is created in the YuiRestClient is identified with a 'filter' that identifies the object. This class provides methods to work with those filters.

Class and object methods

Class attributes:

{resolved} - boolean to indicate that regex matched. On initialization of an object this will be 1 for standard arguments and 0 if the argument contains a reglular expression.
{regex} - a hash that stores the regex in {k, v}. If the argument list contains a regular expression then this is stored in the regex attribute as a hash with a key 'k' and a value 'v', where 'v' represents the regular expression.
{filter} - a hash that contains the filter arguments. If the argument list contains a regex, then this regex is removed from {filter} during initialization.

Object methods:

new($args) - create a filter object.

The argument $args is a hash that can contain several key/value pairs to identify an UI object. Key values match the keys in the JSON representation of the UI widgets and values can be either simple strings or regular expressions ( qr/.../).

get_filter() - returns the filter hash used to create the filter object

Note that when a regex was used on creation then this is removed from the filter hash after initialization of the object. You need to call method resolve() to insert a filter with the found match for the regex before calling get_filter() then.

is_resolved() - returns status of regex matching

The method returns the value of the {resolved} attribute. This value will be altered by the resolve() method.

resolve($json) - resolve a regex

This method tries to match the regular expression that was used during object creation. If exactly one match was found the {filter} attribute gets a new key/value pair that holds the key and the true matching value for the regular expression. If the regex is resolved, then the attribute {resolve} is set to 1 (true).