Wayfinder.Processor.BuildParams (Wayfinder Ex v0.1.2)

View Source

We get for each route a map of all their arguments and if they are optional or not.

Example: get "/users/:id", UserController, :show get "/users/:id/:name", UserController, :show

In this case :id is required and :name is optional.

Summary

Types

counts_acc()

@type counts_acc() :: %{
  required(http_method()) => %{required(param_name()) => param_count()}
}

http_method()

@type http_method() :: String.t()

method_acc()

@type method_acc() :: {counts_acc(), totals_acc()}

param_count()

@type param_count() :: non_neg_integer()

param_name()

@type param_name() :: String.t()

totals_acc()

@type totals_acc() :: %{required(http_method()) => non_neg_integer()}

Functions

build(routes, ordered_params)

@spec build([Phoenix.Router.Route.t()], [{String.t(), atom()}]) ::
  Wayfinder.Processor.Route.params_by_method()

build_param_spec(name, ordered_params, optional_value)

@spec build_param_spec(String.t(), [{String.t(), atom()}], any()) ::
  Wayfinder.Processor.Route.param_spec()

params_count(map)

@spec params_count(Wayfinder.Processor.Route.t() | Phoenix.Router.Route.t()) ::
  non_neg_integer()