module Asciidoctor::Extensions::ProcessorDsl

Internal: Overlays a builder DSL for configuring the Processor instance. Includes a method to define configuration options and another to define the {Processor#process} method.

Public Instance Methods

option(key, value) click to toggle source
# File lib/asciidoctor/extensions.rb, line 257
def option key, value
  config[key] = value
end
process(*args, &block) click to toggle source
# File lib/asciidoctor/extensions.rb, line 261
def process *args, &block
  if block_given?
    raise ::ArgumentError, %(wrong number of arguments (given #{args.size}, expected 0)) unless args.empty?
    unless block.binding && self == block.binding.receiver
      # NOTE remap self in process method to processor instance
      context = self
      block.define_singleton_method(:call) {|*m_args| context.instance_exec(*m_args, &block) }
    end
    @process_block = block
  # TODO enable if we want to support passing proc or lambda as argument instead of block
  #elsif ::Proc === args[0]
  #  raise ::ArgumentError, %(wrong number of arguments (given #{args.size - 1}, expected 0)) unless args.size == 1
  #  @process_block = args.shift
  elsif defined? @process_block
    @process_block.call(*args)
  else
    raise ::NotImplementedError, %(#{self.class} ##{__method__} method called before being registered)
  end
end
process_block_given?() click to toggle source
# File lib/asciidoctor/extensions.rb, line 281
def process_block_given?
  defined? @process_block
end