Class: ActionDispatch::Routing::Mapper
Relationships & Source Files | |
Namespace Children | |
Modules:
| |
Classes:
| |
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
|
|
Inherits: | Object |
Defined in: | actionpack/lib/action_dispatch/routing/mapper.rb |
Constant Summary
-
URL_OPTIONS =
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 24[:protocol, :subdomain, :domain, :host, :port]
Scoping
- Included
Resources
- Included
Class Attribute Summary
Class Method Summary
- .normalize_name(name)
-
.normalize_path(path)
Invokes Journey::Router::Utils.normalize_path, then ensures that /(:locale) becomes (/:locale).
- .new(set) ⇒ Mapper constructor Internal use only
Instance Attribute Summary
Resources
- Included
#shallow, #shallow?, #api_only?, #nested_scope?, #param_constraint?, #resource_method_scope?, #resource_scope? |
Base
- Included
Instance Method Summary
CustomUrls
- Included
#direct | Define custom URL helpers that will be added to the application’s routes. |
#resolve | Define custom polymorphic mappings of models to URLs. |
Resources
- Included
Concerns
- Included
Scoping
- Included
#constraints | Parameter Restriction Allows you to constrain the nested routes based on a set of rules. |
#controller | Scopes routes to a specific controller. |
#defaults | Allows you to set default parameters for a route, such as this: |
#namespace | Scopes routes to a specific namespace. |
#scope | Scopes a set of routes to the given default options. |
#merge_action_scope, #merge_as_scope, #merge_blocks_scope, #merge_constraints_scope, #merge_controller_scope, #merge_defaults_scope, #merge_format_scope, #merge_module_scope, #merge_options_scope, #merge_path_names_scope, #merge_path_scope, #merge_shallow_path_scope, #merge_shallow_prefix_scope, #merge_shallow_scope, #merge_to_scope, #merge_via_scope |
Redirection
- Included
HttpHelpers
- Included
#connect | Define a route that recognizes HTTP CONNECT (and GET) requests. |
#delete | Define a route that only recognizes HTTP DELETE. |
#get | Define a route that only recognizes HTTP GET. |
#options | Define a route that only recognizes HTTP OPTIONS. |
#patch | Define a route that only recognizes HTTP PATCH. |
#post | Define a route that only recognizes HTTP POST. |
#put | Define a route that only recognizes HTTP PUT. |
#map_method |
Base
- Included
#has_named_route? | Query if the following named route was already defined. |
#match | Matches a URL pattern to one or more routes. |
#mount | Mount a Rack-based application to be used within the application. |
#with_default_scope, #app_name, #define_generate_prefix, #rails_app? |
Constructor Details
.new(set) ⇒ Mapper
Class Attribute Details
.backtrace_cleaner (rw)
[ GitHub ]# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 27
cattr_accessor :backtrace_cleaner, instance_accessor: false, default: BacktraceCleaner.new
.route_source_locations (rw)
[ GitHub ]# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 26
cattr_accessor :route_source_locations, instance_accessor: false, default: false
Class Method Details
.normalize_name(name)
[ GitHub ]# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 412
def self.normalize_name(name) normalize_path(name)[1..-1].tr("/", "_") end
.normalize_path(path)
Invokes Journey::Router::Utils.normalize_path, then ensures that /(:locale) becomes (/:locale). Except for root cases, where the former is the correct one.
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 397
def self.normalize_path(path) path = Journey::Router::Utils.normalize_path(path) # the path for a root URL at this point can be something like # "/(/:locale)(/:platform)/(:browser)", and we would want # "/(:locale)(/:platform)(/:browser)" reverse "/(", "/((" etc to "(/", "((/" etc path.gsub!(%r{/(\(+)/?}, '\1/') # if a path is all optional segments, change the leading "(/" back to "/(" so it # evaluates to "/" when interpreted with no options. Unless, however, at least # one secondary segment consists of a static part, ex. # "(/:locale)(/pages/:page)" path.sub!(%r{^(\(+)/}, '/\1') if %r{^(\([^)]\))(\(/:[^)]\))*$}.match?(path) path end