`Pattern#from_sting` was introduced in bb207ea7 to support creating
patterns from strings in tests (removing a conditional in the initialize
method that had been there only for the sake of those tests).
`Pattern#build` was introduced in 947ebe9a, and was similarly used only
in tests.
My understanding is that [`Mapping#path`][path] is the only place where
we initialize a `Path::Pattern` in library code.
Since these two methods appear to be used only in tests, this
commit moves them out of the class and into a test helper.
My reasoning for doing this is that I am doing some performance work
that may involve a modification to how `Path::Pattern`s get initialized,
and I will have more confidence in that work if I know for sure that
these methods are test helpers that can be modified freely.
[path]: https://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/routing/mapper.rb#L192-L194
After @kamipo CR feedback we realized `Route#build` wasn't used. As it
is also private API being able to create Routes both with `#new` and
`#build` was redundant.
Scoring routes based on constraints repeated many type conversions that
could be performed in the outer loop. Determinations of score and
fitness also used Array operations that required allocations. Against
my benchmark with a large routeset, this reduced object allocations by
over 30x and wall time by over 3x.
This commit changes route defaults so that explicit defaults are no
longer required where the key is not part of the path. For example:
resources :posts, bucket_type: 'posts'
will be required whenever constructing the url from a hash such as a
functional test or using url_for directly. However using the explicit
form alters the behavior so it's not required:
resources :projects, defaults: { bucket_type: 'projects' }
This changes existing behavior slightly in that any routes which
only differ in their defaults will match the first route rather
than the closest match.
Closes#8814
Move the Journey code underneath the ActionDispatch namespace so
that we don't pollute the global namespace with names that may
be used for models.
Fixesrails/journey#49.