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:
parent
7fc79bc790
commit
a447252ac4
1 changed files with 7 additions and 6 deletions
|
@ -106,18 +106,14 @@ module Mime
|
||||||
result = @index <=> item.index if result == 0
|
result = @index <=> item.index if result == 0
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
def ==(item)
|
|
||||||
@name == item.to_s
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
class AcceptList < Array #:nodoc:
|
class AcceptList < Array #:nodoc:
|
||||||
def assort!
|
def assort!
|
||||||
sort!
|
sort!
|
||||||
|
|
||||||
text_xml_idx = index('text/xml')
|
text_xml_idx = find_item_by_name self, 'text/xml'
|
||||||
app_xml_idx = index(Mime[:xml].to_s)
|
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
|
# Take care of the broken text/xml entry by renaming or deleting it
|
||||||
if text_xml_idx && app_xml_idx
|
if text_xml_idx && app_xml_idx
|
||||||
|
@ -154,6 +150,11 @@ module Mime
|
||||||
map! { |i| Mime::Type.lookup(i.name) }.uniq!
|
map! { |i| Mime::Type.lookup(i.name) }.uniq!
|
||||||
to_a
|
to_a
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def find_item_by_name(array, name)
|
||||||
|
array.index { |item| item.name == name }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
|
|
Loading…
Reference in a new issue