class Temple::Mixins::CompiledDispatcher::DispatchNode

@api private

def compile(level = 0, call_parent = nil)

def compile(level = 0, call_parent = nil)
  call_method = method ? (level == 0 ? "#{method}(*exp)" :
                          "#{method}(*exp[#{level}..-1])") : call_parent
  if empty?
    raise 'Invalid dispatcher node' unless method
    call_method
  else
    code = "case(exp[#{level}])\n"
    each do |key, child|
      code << "when #{key.inspect}\n  " <<
        child.compile(level + 1, call_method).gsub("\n".freeze, "\n  ".freeze) << "\n".freeze
    end
    code << "else\n  " << (call_method || 'exp') << "\nend"
  end
end

def initialize

def initialize
  super { |hsh,key| hsh[key] = DispatchNode.new }
  @method = nil
end