class ActionDispatch::Routing::RoutesProxy
Experimental RBS support (using type sampling data from the type_fusion
project).
# sig/action_dispatch/routing/routes_proxy.rbs class ActionDispatch::Routing::RoutesProxy def merge_script_names: (String previous_script_name, String new_script_name) -> String end
:nodoc:
def initialize(routes, scope, helpers, script_namer = nil)
def initialize(routes, scope, helpers, script_namer = nil) @routes, @scope = routes, scope @helpers = helpers @script_namer = script_namer end
def merge_script_names(previous_script_name, new_script_name)
Experimental RBS support (using type sampling data from the type_fusion
project).
def merge_script_names: (String previous_script_name, String new_script_name) -> String
This signature was generated using 1 sample from 1 application.
about since it depends on the specific request, but use our
context via ENV["SCRIPT_NAME"], which `mount` doesn't know
Keeps the part of the script name provided by the global
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
def method_missing(method, *args)
def method_missing(method, *args) if @helpers.respond_to?(method) self.class.class_eval <<-RUBY, __FILE__, __LINE__ + 1 def #{method}(*args) options = args.extract_options! options = url_options.merge((options || {}).symbolize_keys) if @script_namer options[:script_name] = merge_script_names( options[:script_name], @script_namer.call(options) ) end args << options @helpers.#{method}(*args) end RUBY public_send(method, *args) else super end end
def respond_to_missing?(method, _)
def respond_to_missing?(method, _) super || @helpers.respond_to?(method) end
def url_options
def url_options scope.send(:_with_routes, routes) do scope.url_options end end