diff options
Diffstat (limited to 'actionpack/lib/action_dispatch/routing/route_set.rb')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/route_set.rb | 85 |
1 files changed, 6 insertions, 79 deletions
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index d7693bdcee..b4c861d306 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -6,7 +6,6 @@ require 'active_support/core_ext/object/to_query' require 'active_support/core_ext/hash/slice' require 'active_support/core_ext/module/remove_method' require 'active_support/core_ext/array/extract_options' -require 'active_support/core_ext/string/filters' require 'action_controller/metal/exceptions' require 'action_dispatch/http/request' require 'action_dispatch/routing/endpoint' @@ -87,7 +86,7 @@ module ActionDispatch # named routes. class NamedRouteCollection #:nodoc: include Enumerable - attr_reader :routes, :url_helpers_module + attr_reader :routes, :url_helpers_module, :path_helpers_module def initialize @routes = {} @@ -102,14 +101,6 @@ module ActionDispatch @path_helpers.include?(key) || @url_helpers.include?(key) end - def helpers - ActiveSupport::Deprecation.warn(<<-MSG.squish) - `named_routes.helpers` is deprecated, please use `route_defined?(route_name)` - to see if a named route was defined. - MSG - @path_helpers + @url_helpers - end - def helper_names @path_helpers.map(&:to_s) + @url_helpers.map(&:to_s) end @@ -138,7 +129,7 @@ module ActionDispatch @url_helpers_module.send :undef_method, url_name end routes[key] = route - define_url_helper @path_helpers_module, route, path_name, route.defaults, name, LEGACY + define_url_helper @path_helpers_module, route, path_name, route.defaults, name, PATH define_url_helper @url_helpers_module, route, url_name, route.defaults, name, UNKNOWN @path_helpers << path_name @@ -170,25 +161,6 @@ module ActionDispatch routes.length end - def path_helpers_module(warn = false) - if warn - mod = @path_helpers_module - helpers = @path_helpers - Module.new do - include mod - - helpers.each do |meth| - define_method(meth) do |*args, &block| - ActiveSupport::Deprecation.warn("The method `#{meth}` cannot be used here as a full URL is required. Use `#{meth.to_s.sub(/_path$/, '_url')}` instead") - super(*args, &block) - end - end - end - else - @path_helpers_module - end - end - class UrlHelper # :nodoc: def self.create(route, options, route_name, url_strategy) if optimize_helper?(route) @@ -271,7 +243,7 @@ module ActionDispatch controller_options = t.url_options options = controller_options.merge @options hash = handle_positional_args(controller_options, - deprecate_string_options(inner_options) || {}, + inner_options || {}, args, options, @segment_keys) @@ -299,22 +271,6 @@ module ActionDispatch result.merge!(inner_options) end - - DEPRECATED_STRING_OPTIONS = %w[controller action] - - def deprecate_string_options(options) - options ||= {} - deprecated_string_options = options.keys & DEPRECATED_STRING_OPTIONS - if deprecated_string_options.any? - msg = "Calling URL helpers with string keys #{deprecated_string_options.join(", ")} is deprecated. Use symbols instead." - ActiveSupport::Deprecation.warn(msg) - deprecated_string_options.each do |option| - value = options.delete(option) - options[option.to_sym] = value - end - end - options - end end private @@ -346,34 +302,7 @@ module ActionDispatch # :stopdoc: # strategy for building urls to send to the client PATH = ->(options) { ActionDispatch::Http::URL.path_for(options) } - FULL = ->(options) { ActionDispatch::Http::URL.full_url_for(options) } UNKNOWN = ->(options) { ActionDispatch::Http::URL.url_for(options) } - LEGACY = ->(options) { - if options.key?(:only_path) - if options[:only_path] - ActiveSupport::Deprecation.warn(<<-MSG.squish) - You are calling a `*_path` helper with the `only_path` option - explicitly set to `true`. This option will stop working on - path helpers in Rails 5. Simply remove the `only_path: true` - argument from your call as it is redundant when applied to a - path helper. - MSG - - PATH.call(options) - else - ActiveSupport::Deprecation.warn(<<-MSG.squish) - You are calling a `*_path` helper with the `only_path` option - explicitly set to `false`. This option will stop working on - path helpers in Rails 5. Use the corresponding `*_url` helper - instead. - MSG - - FULL.call(options) - end - else - PATH.call(options) - end - } # :startdoc: attr_accessor :formatter, :set, :named_routes, :default_scope, :router @@ -508,12 +437,10 @@ module ActionDispatch if supports_path path_helpers = routes.named_routes.path_helpers_module - else - path_helpers = routes.named_routes.path_helpers_module(true) - end - include path_helpers - extend path_helpers + include path_helpers + extend path_helpers + end # plus a singleton class method called _routes ... included do |