Method: IsoDoc::Convert#swap_renderer

Defined in:
lib/isodoc/convert.rb

#swap_renderer(oldklass, newklass, file, input_filename, debug) ⇒ Object

use a different class than self for rendering, as a result of document-specific criteria but pass on any singleton methods defined on top of the self instance



189
190
191
192
193
194
195
196
197
198
# File 'lib/isodoc/convert.rb', line 189

def swap_renderer(oldklass, newklass, file, input_filename, debug)
  ref = oldklass # avoid oldklass == self for indirection of methods
  oldklass.singleton_methods.each do |x|
    newklass.define_singleton_method(x) do |*args|
      ref.public_send(x, *args)
    end
  end
  oldklass.singleton_methods.empty? or
    newklass.convert_init(file, input_filename, debug)
end