     alias = Keyword.get(opts, :alias)
     if alias, do: alias = Atom.to_string(alias)
 
-    as = Keyword.get(opts, :as)
-    scope = {path, alias, as, []}
+    as    = Keyword.get(opts, :as)
+    scope = %Scope{path: path, alias: alias, as: as, pipes: []}
     update_stack(module, fn stack -> [scope|stack] end)
   end
 

  @doc """
  Returns true if modules definition is currently within a scope block
  """
  def within_scope?(module) do
    case get_stack(module) do
      [{nil, nil, nil, []}] -> false
      _ -> true
    end
  end

  defp join(module, path, alias, as) do
    stack = get_stack(module)


  defp join_path(stack, path) do
    "/" <>
      ([Plug.Router.Utils.split(path)|extract(stack, :path)]
       |> Enum.reverse()
       |> Enum.concat()
       |> Enum.join("/"))
  end

  defp join_alias(stack, alias) when is_atom(alias) do
    [alias|extract(stack, :alias)]
    |> Enum.reverse()
    |> Module.concat()
  end

  defp join_as(_stack, nil), do: nil
  defp join_as(stack, as) when is_atom(as) or is_binary(as) do
    [as|extract(stack, :as)]
    |> Enum.reverse()
    |> Enum.join("_")
  end

  defp join_pipe_through(stack) do
    for scope <- Enum.reverse(stack),
        item <- scope.pipes,
        do: item
  end

  defp extract(stack, attr) do
    for scope <- stack,
        item = scope[attr],
        do: item
  end

