You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Due to the fact that HTML::Pipeline is a class, not a module, there is risk that an add-on filter will prematurely define this class before it's extended in the core library, which causes the notorious "superclass mismatch" exception.
Here's an example of where this happens. While create a new gem for the BarFilter, we define a version file:
If we load this at the top of a gemspec file, for instance, then if we attempt to load 'html/pipeline', it goes 💥.
Normally the way these things are defined (as far as I understand it), the top-level type in a gem is a module, not a class. One way to accomplish this without breaking the current API (much), is to define the class method new on the module that instantiates the concrete class. Something like:
moduleHTMLmodulePipelinedefself.newfilters,default_context={},result_class=nilEngine.newfilters,default_context,result_classendclassEngine# relocate Pipeline class definition hereendendend
The other solution, which I used in html-pipeline-asciidoc_filter, is to put the filter class in a different module for the purpose of holding the VERSION constant.
Due to the fact that HTML::Pipeline is a class, not a module, there is risk that an add-on filter will prematurely define this class before it's extended in the core library, which causes the notorious "superclass mismatch" exception.
Here's an example of where this happens. While create a new gem for the BarFilter, we define a version file:
lib/html/pipeline/bar_filter/version.rb
If we load this at the top of a gemspec file, for instance, then if we attempt to load 'html/pipeline', it goes 💥.
Normally the way these things are defined (as far as I understand it), the top-level type in a gem is a module, not a class. One way to accomplish this without breaking the current API (much), is to define the class method
new
on the module that instantiates the concrete class. Something like:The other solution, which I used in html-pipeline-asciidoc_filter, is to put the filter class in a different module for the purpose of holding the VERSION constant.
Either way, I think this is an important issue to address to minimize the challenges of creating an add-on filter.
The text was updated successfully, but these errors were encountered: