Connector
view release on metacpan or search on metacpan
## exists
## get
Basic method to obtain a scalar value at the leaf of the config tree.
my $value = $connector->get('smartcard.owners.tokenid.bob');
Each implementation must also accept an arrayref as path. The path is
contructed from the elements. The default behaviour allows strings using
the delimiter character inside an array element. If you want each array
element to be parsed, you need to pass "RECURSEPATH => 1" to the constructor.
my $value = $connector->get( [ 'smartcard','owners','tokenid','bob.builder' ] );
Some implementations accept control parameters, which can be passed by
_params_, which is a hash ref of key => value pairs.
my $value = $connector->get( 'smartcard.owners.tokenid.bob' , { version => 1 } );
## get\_list
This method is only valid if it is called on a "n-1" depth node representing
an ordered list of items (array). The return value is an array with all
values present below the node.
my @items = $connector->get_list( 'smartcard.owners.tokenid' );
## get\_size
This method is only valid if it is called on a "n-1" depth node representing
an ordered list of items (array). The return value is the number of elements
in this array (including undef elements if they are explicitly given).
my $count = $connector->get_size( 'smartcard.owners.tokens.bob' );
If the node does not exist, 0 is returned.
## get\_hash
This method is only valid if it is called on a "n-1" depth node representing
a key => value list (hash). The return value is a hash ref.
my %data = %{$connector->get_hash( 'smartcard.owners.tokens.bob' )};
## get\_keys
This method is only valid if it is called on a "n-1" depth node representing
a key => value list (hash). The return value is an array holding the
values of all keys (including undef elements if they are explicitly given).
my @keys = $connector->get_keys( 'smartcard.owners.tokens.bob' );
If the node does not exist, an empty list is returned.
## get\_reference \[deprecated\]
Rarely used, returns the value of a reference node. Currently used by
Connector::Multi in combination with Connector::Proxy::Config::Versioned
to create internal links and cascaded connectors. See Connector::Multi
for details.
## set
The set method is a "all in one" implementation, that is used for either type
of value. If the value is not a scalar, it must be passed by reference.
$connector->set('smartcard.owners.tokenid.bob', $value, $params);
The _value_ parameter holds a scalar or ref to an array/hash with the data to
be written. _params_ is a hash ref which holds additional parameters for the
operation and can be undef if not needed.
# STRUCTURAL METHODS
## get\_meta
This method returns some structural information about the current node as
hash ref. At minimum it must return the type of node at the current path.
Valid values are _scalar, list, hash, reference_. The types match the
accessor methods given above (use `get` for _scalar_).
my $meta = $connector->get_meta( 'smartcard.owners' );
my $type = $meta->{TYPE};
When you call a proxy connector without sufficient arguments to perform the
query, you will receive a value of _connector_ for type. Running a get\_\*
method against such a node will cause the connector to die!
## cleanup
Advise connectors to close, release or flush any open handle or sessions.
Should be called directly before the program terminates. Connectors might
be stale and not respond any longer after this was called.
# IMPLEMENTATION GUIDELINES
You SHOULD use the \_node\_not\_exists method if the requested path does not exist
or has an undefined value. This will internally take care of the _die\_on\_undef_
setting and throw an exception or return undef. So you can just write:
if (path not exists || not defined val) {
return $self->_node_not_exists( pathspec );
}
As connectors are often used in eval constructs where the error messages
are swallowed you SHOULD log a verbose error before aborting with
die/confess. You can use the \_log\_and\_die method for this purpose. It will
send a message to the logger on error level before calling "die $message".
## path building
You should always pass the first parameter to the private `_build_path`
method. This method converts any valid path spec representation to a valid
path. It takes care of the RECURSEPATH setting and returns the path
elements as list.
## Supported methods
( run in 1.172 second using v1.01-cache-2.11-cpan-5837b0d9d2c )