Move setting :scope_level_resource to resource_scope

Originally with_scope_level was exclusively for managing scope levels with
resources, however it is now used for other things so it makes more sense
to move the responsibility for setting the :scope_level_resource to the
resource_scope method. This eliminates repeatedly setting it to the same
resource as each resource method scope is evaluated.

(cherry picked from commit ed0fb4ae7ea28cf3eecce6ec02650bcffc7c7657)
Only use shallow nested scope when depth is > 1

By tracking the depth of resource nesting we can push the need for nested
shallow scoping to only those routes that are nested more than one deep.
This allows us to keep the fix for #12498 and fix the regression in #14224.

Fixes #14224.

(cherry picked from commit dcc91a04a177466516dac12abc358c590743fa71)
Pull namespace defaults out of the options hash

If a developer has specified either :path or :as in the options hash then
these should be used as the defaults for :shallow_path and :shallow_prefix.

Fixes #14241.

(cherry picked from commit 8711086f5a2e73cd068434a5fafef258ba9f4fe1)
Copy shallow options from normal options when using scope

If the options :shallow_prefix and :shallow_path are not set in the
scope options then copy them from the normal :as and :path options
if they are set.

(cherry picked from commit af4c9b78ff1c967cc1aaef14d34205ef92db8134)