NAME

Data::Identifier::Interface::Subobjects - format independent identifier object

VERSION

version v0.17

SYNOPSIS

use parent 'Data::Identifier::Interface::Subobjects';

(since v0.16, experimental)

Interface for modules implementing so_*().

Note: This interface reserves all method (and constant) names so_* and SO_*.

Note: This interface is experimental. Details may change or it may be removed completely.

This package inherits from Data::Identifier::Interface::Userdata.

METHODS

so_attach

$obj->so_attach(key => $obj, ...);
# or:
$obj->so_attach(key => $obj, ..., weak => 1);

Attaches objects of the given type.

If an object is allready attached for the given key this method dies unless the object is actually the same.

If weak is set to a true value the object reference becomes weak.

Returns itself.

so_get

my $so = $obj->so_get($name [, %opts ]);

Get a subobject by the given $name.

If no such subobject is known, this method dies.

The following, all optional, options are supported:

default

The default value to return if no other value is available. This can be set to undef to change the method from dieing in failture to returning undef.

no_defaults

This option has currently no effect and is ignored.

_subobject_provider

my $userdata = $obj->_subobject_provider;

This method is used by the default implementation of "so_attach" and "so_get". It provides the backend storage for subobjects.

For every passed object it returns an instance of a hashref (initially empty) that is kept inside the object.

The default implementation expects the object to be a (blessed) hashref. It uses the key subobjects to store the hashref. It is equivalent to:

return $obj->{subobjects} //= {};

If all other methods are overridden this method can stay unimplemented.

CONSTANTS

KEYS

my @list = Data::Identifier::Interface::Subobjects->KEYS;

Returns the keys supported for subobjects.

AUTHOR

Löwenfelsen UG (haftungsbeschränkt) <support@loewenfelsen.net>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2023-2025 by Löwenfelsen UG (haftungsbeschränkt) <support@loewenfelsen.net>.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)