Sha256: 2ca8d92eeeeb931e91f9342a2597d409d0b5a4ffea083a924a4194bd8e8bb7a8

Contents?: true

Size: 523 Bytes

Versions: 12

Compression:

Stored size: 523 Bytes

Contents

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

12 entries across 12 versions & 1 rubygems

Version Path
acfs-0.48.2 lib/acfs/response/formats.rb
acfs-1.0.1 lib/acfs/response/formats.rb
acfs-0.48.1 lib/acfs/response/formats.rb
acfs-1.0.0 lib/acfs/response/formats.rb
acfs-0.48.0 lib/acfs/response/formats.rb
acfs-0.47.0 lib/acfs/response/formats.rb
acfs-0.46.0 lib/acfs/response/formats.rb
acfs-0.45.0 lib/acfs/response/formats.rb
acfs-0.44.0 lib/acfs/response/formats.rb
acfs-0.43.2 lib/acfs/response/formats.rb
acfs-0.43.1 lib/acfs/response/formats.rb
acfs-0.43.0 lib/acfs/response/formats.rb