Sha256: 55a640ac5efd6f4879518d006c6caeb0a92013152a50db870bda192cc25873be

Contents?: true

Size: 524 Bytes

Versions: 10

Compression:

Stored size: 524 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

10 entries across 10 versions & 1 rubygems

Version Path
acfs-1.3.2 lib/acfs/response/formats.rb
acfs-1.3.1 lib/acfs/response/formats.rb
acfs-1.3.0 lib/acfs/response/formats.rb
acfs-1.2.1 lib/acfs/response/formats.rb
acfs-0.50.0 lib/acfs/response/formats.rb
acfs-1.2.0 lib/acfs/response/formats.rb
acfs-0.49.1 lib/acfs/response/formats.rb
acfs-1.1.1 lib/acfs/response/formats.rb
acfs-0.49.0 lib/acfs/response/formats.rb
acfs-1.1.0 lib/acfs/response/formats.rb