in reply to Re: Keeping relationally child objects alive with Moo
in thread Keeping relationally child objects alive with Moo

That's reassuring, but what about the way I am doing it:
$self->attribute->{'key'} = $childObject;
Is this the right way to assign one of many relationally child objects to the relational parent object? Having had some problems I worked around explicitly, I am worried that the reference to the inner object in the above construction is too remote to persist indefinitely just because the parent object persists indefinitely.

One world, one people

Replies are listed 'Best First'.
Re^3: Keeping relationally child objects alive with Moo
by Corion (Patriarch) on Sep 21, 2017 at 14:17 UTC

    So, what does ->attribute return?

    If it returns a hashref that is kept alive by $self, you should be fine.

    If it returns something else, you might have a problem.

    But we cannot tell without seeing some representative example.

      The hash keys persist, but sometimes the values (objects) get destroyed/go undef even though obviously $self and all its immediate attributes are still alive and well.

      One world, one people