# File lib/blockenspiel/impl.rb, line 256
  def self.invoke(*args_, &builder_block_)
    # This method itself is responsible for parsing the args to invoke,
    # and handling the dynamic target generation. It then passes control
    # to one of the _invoke_with_* methods.

    # The arguments.
    block_ = nil
    eval_str_ = nil
    target_ = nil
    opts_ = {}

    # Get the code
    case args_.first
    when ::String
      eval_str_ = args_.shift
    when ::Proc
      block_ = args_.shift
    end

    # Get the target, performing dynamic target generation if requested
    if builder_block_
      builder_ = ::Blockenspiel::Builder.new
      invoke(builder_block_, builder_)
      target_ = builder_._create_target
      args_.shift if args_.first.nil?
    else
      target_ = args_.shift
      unless target_
        raise ::ArgumentError, "No DSL target provided"
      end
    end

    # Get the options hash
    if args_.first.kind_of?(::Hash)
      opts_ = args_.shift
    end
    if args_.size > 0
      raise ::ArgumentError, "Unexpected arguments"
    end

    # Invoke
    if block_
      _invoke_with_block(block_, target_, opts_)
    else
      _invoke_with_string(eval_str_, target_, opts_)
    end
  end