diff options
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_dispatch/http/mime_negotiation.rb | 29 |
1 files changed, 2 insertions, 27 deletions
diff --git a/actionpack/lib/action_dispatch/http/mime_negotiation.rb b/actionpack/lib/action_dispatch/http/mime_negotiation.rb index 6544aff7d2..ff336b7354 100644 --- a/actionpack/lib/action_dispatch/http/mime_negotiation.rb +++ b/actionpack/lib/action_dispatch/http/mime_negotiation.rb @@ -76,7 +76,7 @@ module ActionDispatch variant = Array(variant) if variant.all? { |v| v.is_a?(Symbol) } - @variant = VariantInquirer.new(variant) + @variant = ActiveSupport::ArrayInquirer.new(variant) else raise ArgumentError, "request.variant must be set to a Symbol or an Array of Symbols. " \ "For security reasons, never directly set the variant to a user-provided value, " \ @@ -86,7 +86,7 @@ module ActionDispatch end def variant - @variant ||= VariantInquirer.new + @variant ||= ActiveSupport::ArrayInquirer.new end # Sets the \format by string extension, which can be used to force custom formats @@ -141,31 +141,6 @@ module ActionDispatch order.include?(Mime::ALL) ? format : nil end - class VariantInquirer # :nodoc: - delegate :each, :empty?, to: :@variants - - def initialize(variants = []) - @variants = variants - end - - def any?(*candidates) - (@variants & candidates).any? - end - - def to_ary - @variants - end - - private - def method_missing(name, *args) - if name[-1] == '?' - any? name[0..-2].to_sym - else - super - end - end - end - protected BROWSER_LIKE_ACCEPTS = /,\s*\*\/\*|\*\/\*\s*,/ |