1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

remove == from AcceptItem

Remove nonsense definition of == from `AcceptItem`.  The definition only
compared names and not `q` values or even object identity.  The only use
was in the `assort!` method that really just wanted the index of the
item given the item's name.  Instead we just change the caller to use
`index` with the block form.
This commit is contained in:
Aaron Patterson 2016-01-27 18:05:15 -08:00
parent 7fc79bc790
commit a447252ac4

View file

@ -106,18 +106,14 @@ module Mime
result = @index <=> item.index if result == 0
result
end
def ==(item)
@name == item.to_s
end
end
class AcceptList < Array #:nodoc:
def assort!
sort!
text_xml_idx = index('text/xml')
app_xml_idx = index(Mime[:xml].to_s)
text_xml_idx = find_item_by_name self, 'text/xml'
app_xml_idx = find_item_by_name self, Mime[:xml].to_s
# Take care of the broken text/xml entry by renaming or deleting it
if text_xml_idx && app_xml_idx
@ -154,6 +150,11 @@ module Mime
map! { |i| Mime::Type.lookup(i.name) }.uniq!
to_a
end
private
def find_item_by_name(array, name)
array.index { |item| item.name == name }
end
end
class << self