Sha256: 9abe0e4150107c18326d32365f735374efd4ad353c9322f535056d968f345468

Contents?: true

Size: 555 Bytes

Versions: 7

Compression:

Stored size: 555 Bytes

Contents

# frozen_string_literal: true

require 'action_dispatch'

module Acfs
  class Response
    # Quick accessors for format handling.
    module Formats
      def content_type
        @content_type ||= read_content_type
      end

      def json?
        content_type == Mime[:json]
      end

      private

      def read_content_type
        return 'text/plain' unless headers && headers['Content-Type']

        content_type = headers['Content-Type'].split(/;\s*\w+="?\w+"?/).first
        Mime::Type.parse(content_type).first
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
acfs-2.0.0 lib/acfs/response/formats.rb
acfs-1.7.0 lib/acfs/response/formats.rb
acfs-1.6.0 lib/acfs/response/formats.rb
acfs-1.5.1 lib/acfs/response/formats.rb
acfs-1.5.0 lib/acfs/response/formats.rb
acfs-1.4.0 lib/acfs/response/formats.rb
acfs-1.3.4 lib/acfs/response/formats.rb