module Temple::Mixins::CompiledDispatcher

def replace_dispatcher(exp)

def replace_dispatcher(exp)
  tree = DispatchNode.new
  dispatched_methods.each do |method|
    method.split('_')[1..-1].inject(tree) {|node, type| node[type.to_sym] }.method = method
  end
  self.class.class_eval %{
    def dispatcher(exp)
      if self.class == #{self.class}
        #{tree.compile}
      else
        replace_dispatcher(exp)
      end
    end
  }
  dispatcher(exp)
end