Sha256: 9a0005b6ecbdd70192e6cc5cc32c2f921f456ba5ca7a30b5791375bbc8230802

Contents?: true

Size: 754 Bytes

Versions: 1

Compression:

Stored size: 754 Bytes

Contents

module Datomic
  class Client
    class Response
      # Response body as a string
      attr_reader :body
      # Underlying Net:HTTP response
      attr_reader :net_http

      def initialize(body, response, request)
        @body = body
        @args = request.args
        @net_http = response
        # used to parse response cookies and headers
        @rest_client_response = RestClient::Response.create(body, response, @args)
      end

      # converts an EDN body to a data structure i.e. array, hash
      def data
        @data ||= EDN.read @body
      end

      [:code, :headers, :cookies, :raw_headers].each do |meth|
        define_method(meth) do
          @rest_client_response.public_send(meth)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
datomic-client-0.2.0 lib/datomic/client/response.rb