 defmodule Phoenix.Router.Scope do
+  alias Phoenix.Router.Scope
   @moduledoc false
 
   @stack :phoenix_router_scopes
   @pipes :phoenix_pipeline_scopes
 
+  @derive [Access]
+  defstruct path: nil, alias: nil, as: nil, pipes: []
+
   @doc """
   Initializes the scope.
   """
   def init(module) do
-    Module.put_attribute(module, @stack, [{nil, nil, nil, []}])
+    Module.put_attribute(module, @stack, [%Scope{}])
     Module.put_attribute(module, @pipes, HashSet.new)
   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)

    alias = Keyword.get(opts, :alias)
    if alias, do: alias = Atom.to_string(alias)

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

