Open vivien opened 6 years ago
The simplest way, of course, is to replace class << self
with module_function
. But I'm not convinced we want to export all the functions.
I came up with away to selectively export, while still keeping the methods defined in self. See #3198 and let me know what you think about that approach.
I wish Ruby had a way to promote a static method to a module function, but it doesn't seem to work that way. My workaround seems to be the next best thing.
I have to ask, is this really saving you that may characters? The Extensions module doesn't really provide utility functions, so promoting them to top level functions feels out of place. I could see it if these were pure functions, but they aren't.
Because
register
is defined insideclass << self
, it is currently not possible to write an extension like this:Much of the stdlib uses
module_function
, so we get used to it working like that. I think this seems more intuitive for anyone, instead of calling explicitlyAsciidoctor::Extensions.register
.Can
register
and friends be consideredmodule_function
instead?