Class: HttpStub::Configurer::Request::StubResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/http_stub/configurer/request/stub_response.rb

Instance Method Summary collapse

Constructor Details

#initialize(id, args) ⇒ StubResponse

Returns a new instance of StubResponse.



7
8
9
10
# File 'lib/http_stub/configurer/request/stub_response.rb', line 7

def initialize(id, args)
  @id   = id
  @args = args
end

Instance Method Details

#fileObject



21
22
23
24
25
26
27
28
# File 'lib/http_stub/configurer/request/stub_response.rb', line 21

def file
  if contains_file?
    args = { id: @id, type: @args[:headers]["content-type"] }.merge(@args[:body][:file])
    HttpStub::Configurer::Request::StubResponseFile.new(args)
  else
    nil
  end
end

#payloadObject



12
13
14
15
16
17
18
19
# File 'lib/http_stub/configurer/request/stub_response.rb', line 12

def payload
  {
    status:           @args[:status] || "",
    headers:          @args[:headers] || {},
    body:             @args[:body],
    delay_in_seconds: @args[:delay_in_seconds] || ""
  }
end