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
11
12
13
# File 'lib/http_stub/configurer/request/stub_response.rb', line 7

def initialize(id, args)
  @id               = id
  @status           = args[:status] || ""
  @headers          = (args[:headers] || {}).with_indifferent_and_insensitive_access
  @body             = args[:json].try(:to_json) || args[:body]
  @delay_in_seconds = args[:delay_in_seconds] || ""
end

Instance Method Details

#fileObject



19
20
21
# File 'lib/http_stub/configurer/request/stub_response.rb', line 19

def file
  contains_file? ? create_response_file : nil
end

#payloadObject



15
16
17
# File 'lib/http_stub/configurer/request/stub_response.rb', line 15

def payload
  { status: @status, headers: @headers, body: @body, delay_in_seconds: @delay_in_seconds }
end