Sha256: 6e6b31b3df58a4977f90d6d64d294eb0f24094f68401bb3268583d03ac828b8c

Contents?: true

Size: 591 Bytes

Versions: 11

Compression:

Stored size: 591 Bytes

Contents

module Koala
  module HTTPService
    class Response
      attr_reader :status, :body, :headers

      # Creates a new Response object, which standardizes the response received by Facebook for use within Koala.
      def initialize(status, body, headers)
        @status = status
        @body = body
        @headers = headers
      end

      def data
        # quirks_mode is needed because Facebook sometimes returns a raw true or false value --
        # in Ruby 2.4 we can drop that.
        @data ||= JSON.parse(body, quirks_mode: true) unless body.empty?
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
koala-3.6.0 lib/koala/http_service/response.rb
koala-3.5.0 lib/koala/http_service/response.rb
koala-3.4.0 lib/koala/http_service/response.rb
koala-3.3.0 lib/koala/http_service/response.rb
koala-3.2.0 lib/koala/http_service/response.rb
koala-3.1.0 lib/koala/http_service/response.rb
koala-3.0.0 lib/koala/http_service/response.rb
koala-3.0.0.rc2 lib/koala/http_service/response.rb
koala-3.0.0.rc lib/koala/http_service/response.rb
koala-3.0.0.beta3 lib/koala/http_service/response.rb
koala-3.0.0.beta2 lib/koala/http_service/response.rb