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

load_schema with shorten is broken #22

Closed
dagolden opened this issue Jan 18, 2013 · 4 comments
Closed

load_schema with shorten is broken #22

dagolden opened this issue Jan 18, 2013 · 4 comments
Milestone

Comments

@dagolden
Copy link
Contributor

When shortening, the shortened name is a glob alias, which causes class methods on the alias to get a class name that doesn't correspond to a metaclass registered with Class::MOP.

I think the fix is to do what aliased.pm does, which is to import a constant subroutine that returns the original package name, e.g. something like this:

*{ join q{::} => $callpack, $alias } = sub () { $package };
@dagolden
Copy link
Contributor Author

Aha. Problem with aliased approach is that has to be done during BEGIN. So we could add an import API like this:

use Mongoose load_schema => { search_path => "My::Model", shorten => 1 };

That could then be made to do what load_schema does now except do the aliased.pm approach to aliasing.

But if load_schema is called at runtime, we have to clone the meta object in load_schema():

Class::MOP::store_metaclass_by_name( $short_name, $module->meta );

That appears to work, but feels brittle.

Not sure what you want to do.

@dagolden
Copy link
Contributor Author

See SHA: 8ac44e4

@dagolden dagolden reopened this Jan 18, 2013
@dagolden
Copy link
Contributor Author

Whoops. Wrong button. (Sigh)

rodrigolive added a commit that referenced this issue Jan 21, 2013
- author David Golden (dagolden)
- fixes issue GH #22
@rodrigolive
Copy link
Owner

There. For now, cloning the metadata feels like it will do. The new load_schema API on use Mongoose feels a bit out of place, need to sleep on it some more.

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