package MyClass; use Moo; use MooX::NonOO; ... as_function methods => [ ... ], # names of methods to allow as functions args => [ ... ]; # constructor arguments for the default instance
I have some legacy modules that allow non-OO usage, e.g. you can just call methods as functions. If the first argument isn't a blessed reference to the class, then it uses a default singleton instance.
I'd like to convert the modules to use Moo, and have realized the code can be generalized to a module.
(Yes, I know a lot of people frown on this. I do now, but I'd like to maintain backward compatibility. And arguably OO, while making this module simpler to write, is overkill for some use cases.)
I have a working prototype.
My big question is: 1. Is there already something that does this for Moo (so I don't waste timing writing another module)? 2. Is there a better name for this?