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

new_anon does not work with reblessing #90

Open
bbrtj opened this issue Jul 5, 2024 · 1 comment
Open

new_anon does not work with reblessing #90

bbrtj opened this issue Jul 5, 2024 · 1 comment

Comments

@bbrtj
Copy link
Member

bbrtj commented Jul 5, 2024

A fix is required for new_anon method, which does not work correctly for subclasses, most notably controllers and reblessing. The new subclass of Kelp it creates will have all the module methods attached to it, while the other subclasses will have none. This seemingly obvious bug has gone unnoticed for quite some time, which probably means it's not seeing much use.

A better alternative would be to use what was done for #62 and mark new_anon instances with a special field. Then, Kelp::Module would check that field and change how the method is installed - from adding a method to a class, to adding a method to a hash used by autoload. This must also be adjusted for KelpX::Hooks, which now assumes methods are installed into the package.

Using each Kelp app as a singleton would still be the recommended way, but it would be nice to have new_anon method fixed.

@bbrtj
Copy link
Member Author

bbrtj commented Jul 5, 2024

Idea: add helper functions to Kelp::Util, for example add_method_to_package and replace_method_in_package, and implement all the details inside them. Then use them in both Kelp::Module and KelpX::Hooks.

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

No branches or pull requests

1 participant