Module: MimeFallback::NegotiationExtensions
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/mime_fallback/negotiation_extensions.rb
Instance Method Summary collapse
-
#negotiate_mime_with_fallback(order) ⇒ Object
Override to support mime type fallbacks.
Instance Method Details
#negotiate_mime_with_fallback(order) ⇒ Object
Override to support mime type fallbacks
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/mime_fallback/negotiation_extensions.rb', line 10 def negotiate_mime_with_fallback(order) formats.each do |priority| if priority == Mime::ALL return order.first else # Try to find an exact match to what we're responding to types = Array(priority) + MimeFallback::Type.fallbacks(priority.to_sym) types.each do |fallback| return fallback if order.map(&:to_sym).include?(fallback.to_sym) end if order.include?(priority) return priority end end end order.include?(Mime::ALL) ? formats.first : nil end |