Class: ParallelBatchApi::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/parallel_batch_api/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(res, url, params) ⇒ Response

Returns a new instance of Response.



5
6
7
8
9
# File 'lib/parallel_batch_api/response.rb', line 5

def initialize(res, url, params)
  @status, @header, @body = res
  @url = url
  @params = params
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



3
4
5
# File 'lib/parallel_batch_api/response.rb', line 3

def body
  @body
end

#headerObject (readonly)

Returns the value of attribute header.



3
4
5
# File 'lib/parallel_batch_api/response.rb', line 3

def header
  @header
end

#paramsObject (readonly)

Returns the value of attribute params.



3
4
5
# File 'lib/parallel_batch_api/response.rb', line 3

def params
  @params
end

#statusObject (readonly)

Returns the value of attribute status.



3
4
5
# File 'lib/parallel_batch_api/response.rb', line 3

def status
  @status
end

#urlObject (readonly)

Returns the value of attribute url.



3
4
5
# File 'lib/parallel_batch_api/response.rb', line 3

def url
  @url
end

Instance Method Details

#executeObject



11
12
13
14
15
# File 'lib/parallel_batch_api/response.rb', line 11

def execute
  base_body = ''
  body.each { |str| base_body << str }
  { status: status, header: header, body: JSON.parse(base_body), url: url, key: key }
end

#keyObject



17
18
19
# File 'lib/parallel_batch_api/response.rb', line 17

def key
  "#{params[:controller]}##{params[:action]}"
end