lib/praxis/action_definition.rb
# Determine the content_type to report for a given example,
# using handler_name if possible.
#
# Considers any pre-defined set of values on the content_type attributge
# of the headers.
Determine the content_type to report for a given example,
using handler_name if possible.

Considers any pre-defined set of values on the content_type attributge
of the headers.
Determine the content_type to report for a given example using handler_name if possible . Considers any pre - defined set of values on the content_type attributge of the headers .
def derive_content_type(example, handler_name)
      if example.kind_of? Praxis::Types::MultipartArray
        return MediaTypeIdentifier.load(example.content_type)
      end
       _, content_type_attribute = self.headers && self.headers.attributes.find { |k,v| k.to_s =~ /^content[-_]{1}type$/i }
      if content_type_attribute && content_type_attribute.options.key?(:values)
        content_type_attribute.options[:values].each do |ct|
          mti = MediaTypeIdentifier.load(ct)
          return mti if mti.handler_name == handler_name
        end
        pick = MediaTypeIdentifier.load(content_type_attribute.options[:values].first)
        if Praxis::Application.instance.handlers.include?(pick.handler_name)
          return pick
        else
          return pick + handler_name
        end
      end
      MediaTypeIdentifier.load("application/#{handler_name}")
    end
def derive_content_type ( example , handler_name ) if example . kind_of? Praxis :: Types :: MultipartArray return MediaTypeIdentifier . load ( example . content_type ) end _ , content_type_attribute = self . headers && self . headers . attributes . find { | k , v | k . to_s =~ / ^content[-_]{1}type$ /i } if content_type_attribute && content_type_attribute . options . key? ( :values ) content_type_attribute . options [ :values ] . each do | ct | mti = MediaTypeIdentifier . load ( ct ) return mti if mti . handler_name == handler_name end pick = MediaTypeIdentifier . load ( content_type_attribute . options [ :values ] . first ) if Praxis :: Application . instance . handlers . include? ( pick . handler_name ) return pick else return pick + handler_name end end MediaTypeIdentifier . load ( "application/#{handler_name}" ) end
Determine the content_type to report for a given example,
using handler_name if possible.
Determine the content_type to report for a given example using handler_name if possible .
# MultipartArrays *must* use the provided content_type # if any defined value match the preferred handler_name, return it # otherwise, pick the first # and return that one if it already corresponds to a registered handler # otherwise, add the encoding # generic default encoding
example
<not_specific>
handler_name
<not_specific>