diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2016-01-27 18:05:15 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2016-01-27 18:28:05 -0800 |
commit | a447252ac4c97b06df271c04ddd7530014dd8c86 (patch) | |
tree | 10be640abb842b352feaaa082d28c6e6b6ca378a /actionpack/lib | |
parent | 7fc79bc7907ea53aead3ff8461daedaacbf1cd71 (diff) | |
download | rails-a447252ac4c97b06df271c04ddd7530014dd8c86.tar.gz rails-a447252ac4c97b06df271c04ddd7530014dd8c86.tar.bz2 rails-a447252ac4c97b06df271c04ddd7530014dd8c86.zip |
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.
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_dispatch/http/mime_type.rb | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/actionpack/lib/action_dispatch/http/mime_type.rb b/actionpack/lib/action_dispatch/http/mime_type.rb index 4a57e04c3a..463b5fe405 100644 --- a/actionpack/lib/action_dispatch/http/mime_type.rb +++ b/actionpack/lib/action_dispatch/http/mime_type.rb @@ -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 |