def derive_content_type(example, handler_name)
      # MultipartArrays *must* use the provided content_type
      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)

        # if any defined value match the preferred handler_name, return it
        content_type_attribute.options[:values].each do |ct|
          mti = MediaTypeIdentifier.load(ct)
          return mti if mti.handler_name == handler_name
        end

        # otherwise, pick the first
        pick = MediaTypeIdentifier.load(content_type_attribute.options[:values].first)

        # and return that one if it already corresponds to a registered handler
        # otherwise, add the encoding
        if Praxis::Application.instance.handlers.include?(pick.handler_name)
          return pick
        else
          return pick + handler_name
        end
      end

      # generic default encoding
      MediaTypeIdentifier.load("application/#{handler_name}")
    end
def derive_content_type(example, handler_name)
      # MultipartArrays *must* use the provided content_type
      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)

        # if any defined value match the preferred handler_name, return it
        content_type_attribute.options[:values].each do |ct|
          mti = MediaTypeIdentifier.load(ct)
          return mti if mti.handler_name == handler_name
        end

        # otherwise, pick the first
        pick = MediaTypeIdentifier.load(content_type_attribute.options[:values].first)

        # and return that one if it already corresponds to a registered handler
        # otherwise, add the encoding
        if Praxis::Application.instance.handlers.include?(pick.handler_name)
          return pick
        else
          return pick + handler_name
        end
      end

      # generic default encoding
      MediaTypeIdentifier.load("application/#{handler_name}")
    end
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.