Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support the use of Store objects that do not exist globally, but rather via local variables. #424

Open
gbrgr opened this issue Jan 18, 2022 · 0 comments

Comments

@gbrgr
Copy link

gbrgr commented Jan 18, 2022

Feature Request / Question

Description of Problem:

I am currently trying to implement a Database via my own class. Hence, I define my database via the use of local variables rather than global ones, as, naturally, there is no dedicated syntax for this database type yet (such as in the case of Relational Databases). However, the router component heavily invokes the function elementToPath on store objects that are present in the mapping object handed over to the execute function. The function elementToPath, however, errors when invoked on objects that do not exist globally but are rather bound via local variables.

Potential Solutions:

This is the problematic code segment of elementToPath:

function meta::pure::functions::meta::elementToPath(element:PackageableElement[1], separator:String[1]):String[1]
{
    let path = $element->elementPath();
    if($path->size() == 1,
       | let first = $path->at(0);
         if(is(::, $first),
            | '',
            | $first.name->toOne());,
       | $path->tail()->map(e | $e.name)->joinStrings($separator));
}

If $first does not have a name attribute, the call to toOne() errors. My current workaround is to provide a name attribute to my custom Store. However, I guess this is rather a hack, as in reality, my local object does not have a package path.

One solution would be to provide a wrapper type that lets me expose my custom store as a packagable element so that calls to that functions do not error. Does such a type/solution exist?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant