Class: ActionDispatch::Routing::RoutesProxy
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
self,
UrlFor ,
PolymorphicRoutes
|
|
Inherits: | Object |
Defined in: | actionpack/lib/action_dispatch/routing/routes_proxy.rb |
UrlFor
- Attributes & Methods
Class Method Summary
Instance Attribute Summary
UrlFor
- Included
Instance Method Summary
- #url_options
-
#merge_script_names(previous_script_name, new_script_name)
private
Keeps the part of the script name provided by the global context via [ENV](“SCRIPT_NAME”), which
mount
doesn’t know about since it depends on the specific request, but use our script name resolver for the mount point dependent part. - #method_missing(method, *args) private
- #respond_to_missing?(method, _) ⇒ Boolean private
UrlFor
- Included
#initialize, | |
#route_for | Allows calling direct or regular named route. |
#url_for | Generate a URL based on the options provided, .default_url_options, and the routes defined in |
#url_options | Hook overridden in controller to add request information with .default_url_options. |
#_routes_context, #_with_routes, #full_url_for |
PolymorphicRoutes
- Included
#polymorphic_path | Returns the path component of a URL for the given record. |
#polymorphic_url | Constructs a call to a named RESTful route for the given record and returns the resulting URL string. |
#polymorphic_mapping, #polymorphic_path_for_action, #polymorphic_url_for_action |
Constructor Details
.new(routes, scope, helpers, script_namer = nil) ⇒ RoutesProxy
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) (private)
[ GitHub ]# File 'actionpack/lib/action_dispatch/routing/routes_proxy.rb', line 32
def method_missing(method, *args) if @helpers.respond_to?(method) = args. = .merge(( || {}).symbolize_keys) if @script_namer [:script_name] = merge_script_names( [:script_name], @script_namer.call( ) ) end args << @helpers.public_send(method, *args) else super end end
Class Attribute Details
.default_url_options (rw)
[ GitHub ]# File 'actionpack/lib/action_dispatch/routing/url_for.rb', line 100
class_attribute :
.default_url_options? ⇒ Boolean
(rw)
[ GitHub ]
# File 'actionpack/lib/action_dispatch/routing/url_for.rb', line 100
class_attribute :
Instance Attribute Details
#_routes (readonly)
Alias for #routes.
# File 'actionpack/lib/action_dispatch/routing/routes_proxy.rb', line 13
alias :_routes :routes
#default_url_options (rw)
[ GitHub ]# File 'actionpack/lib/action_dispatch/routing/url_for.rb', line 100
class_attribute :
#default_url_options? ⇒ Boolean
(rw)
[ GitHub ]
# File 'actionpack/lib/action_dispatch/routing/url_for.rb', line 100
class_attribute :
#routes (rw) Also known as: #_routes
[ GitHub ]# File 'actionpack/lib/action_dispatch/routing/routes_proxy.rb', line 12
attr_accessor :scope, :routes
#scope (rw)
[ GitHub ]# File 'actionpack/lib/action_dispatch/routing/routes_proxy.rb', line 12
attr_accessor :scope, :routes
Instance Method Details
#merge_script_names(previous_script_name, new_script_name) (private)
Keeps the part of the script name provided by the global context via [ENV](“SCRIPT_NAME”), which mount
doesn’t know about since it depends on the specific request, but use our script name resolver for the mount point dependent part.
# File 'actionpack/lib/action_dispatch/routing/routes_proxy.rb', line 55
def merge_script_names(previous_script_name, new_script_name) return new_script_name unless previous_script_name resolved_parts = new_script_name.count("/") previous_parts = previous_script_name.count("/") context_parts = previous_parts - resolved_parts + 1 (previous_script_name.split("/").slice(0, context_parts).join("/")) + new_script_name end
#respond_to_missing?(method, _) ⇒ Boolean
(private)
# File 'actionpack/lib/action_dispatch/routing/routes_proxy.rb', line 28
def respond_to_missing?(method, _) super || @helpers.respond_to?(method) end