kelp
kelp copied to clipboard
new_anon does not work with reblessing
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.
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.