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.

Private Instance Methods

option(key, value) click to toggle source
# File lib/asciidoctor/extensions.rb, line 191
def option key, value
  config[key] = value
end
process(*args, &block) click to toggle source
# File lib/asciidoctor/extensions.rb, line 195
def process *args, &block
  if block_given?
    raise ::ArgumentError, %(wrong number of arguments (given #{args.size}, expected 0)) unless args.empty?
    @process_block = block
  # TODO enable if we want to support passing proc or lambda as argument instead of block
  #elsif ::Proc === args[0]
  #  block = args.shift
  #  raise ::ArgumentError, %(wrong number of arguments (given #{args.size}, expected 0)) unless args.empty?
  #  @process_block = block
  elsif defined? @process_block
    # NOTE Proc automatically expands a single array argument
    # ...but lambda doesn't (and we want to accept lambdas too)
    # TODO need a test for this!
    @process_block.call(*args)
  else
    # TODO add exception message here
    raise ::NotImplementedError
  end
end
process_block_given?() click to toggle source
# File lib/asciidoctor/extensions.rb, line 215
def process_block_given?
  defined? @process_block
end