Accessing parent metadata

I want to add some metadata to each page and I use a code like this:

- current_page.add_metadata( {'data_x' => t('data_x')} )

When I am on the child page I want to display data of parent pages. Data must not come from frontmater since I need ruby processing to make them.

Currently it looks like I can access this data from my header template only for the current page. Is there any way to use data that gets generated on parent or other pages ?

It doesn’t have to be metadata, but I need access to variables defined on parent or other pages.

I think that you cannot access variables defined on other pages, since they are NOT an executable code in the context of current page. Only metadata from resource (and frontmatter) are parsed/inspected/run.

When I change title this way on the page itself I can’t get that title when I do current_page.parent.data.title