I'm not sure that I'm understanding you correctly, but if I am, perhaps you want to look into the prefetch functionality to automatically be ready for calling those other related row objects.
For example, in Galileo, when listing all pages (articles) I use this mechanism to get the related author objects for each page object (see here).
Ok so if the point is to store one object in another, you might want to inject some extra data into the object.
UNTESTED:
## some initial checks (run these only once)
# check that method name is available
die "Cannot use method 'extra_data'" if $book->can('extra_data');
# check that the reftype is a hash
require Scalar::Util;
die "Incorrect underlying type" unless Scalar::Util::reftype($book) eq 'HASH';
# check that the key is available
die "Key unavailable" if exists $book->{'my_extra_data'};
{
no strict 'refs';
# create a simple accessor for a hash stored in an object
*{ ref($book) . '::extra_data' } = sub {
my $self = shift;
#return all extra data if called without args
return $self->{my_extra_data} unless @_;
my $key = shift;
if (@_) {
$self->{my_extra_data}{$key} = shift;
}
return $self->{my_extra_data}{$key};
};
}
$book->extra_data( author => $author );
#then later
my $stored_author = $book->extra_data('author');