Class: Acfs::Response

Inherits:
Object
  • Object
show all
Includes:
Formats, Status
Defined in:
lib/acfs/response.rb,
lib/acfs/response/status.rb,
lib/acfs/response/formats.rb

Overview

This represents a response. In addition to an standard HTTP it has a field `data` for storing the encoded body.

Defined Under Namespace

Modules: Formats, Status

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Status

#modified?, #status_code, #success?

Methods included from Formats

#content_type, #json?

Constructor Details

#initialize(request, **opts) ⇒ Response

delegate :status, :status_message, :success?, :modified?, :timed_out?,

:response_body, :response_headers, :response_code, :headers,
to: :response


22
23
24
25
26
27
28
# File 'lib/acfs/response.rb', line 22

def initialize(request, **opts)
  @request  = request
  @status   = opts[:status]  || 0
  @headers  = opts[:headers] || {}
  @body     = opts[:body]    || ''
  @data     = opts[:data]    || nil
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



13
14
15
# File 'lib/acfs/response.rb', line 13

def body
  @body
end

#dataObject

Returns the value of attribute data.



12
13
14
# File 'lib/acfs/response.rb', line 12

def data
  @data
end

#headersObject (readonly)

Returns the value of attribute headers.



13
14
15
# File 'lib/acfs/response.rb', line 13

def headers
  @headers
end

#requestObject (readonly)

Returns the value of attribute request.



13
14
15
# File 'lib/acfs/response.rb', line 13

def request
  @request
end

#statusObject (readonly)

Returns the value of attribute status.



13
14
15
# File 'lib/acfs/response.rb', line 13

def status
  @status
end