Class: HttpStub::Models::Response

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

Constant Summary collapse

SUCCESS =
HttpStub::Models::Response.new("status" => 200, "body" => "OK")
ERROR =
HttpStub::Models::Response.new("status" => 404, "body" => "ERROR")
EMPTY =
HttpStub::Models::Response.new()

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Response

Returns a new instance of Response.



16
17
18
19
20
# File 'lib/http_stub/models/response.rb', line 16

def initialize(options = {})
  @original_options = options
  @response_options = options.clone
  establish_defaults_in(@response_options)
end

Instance Method Details

#bodyObject



30
31
32
# File 'lib/http_stub/models/response.rb', line 30

def body
  @response_options["body"]
end

#delay_in_secondsObject



34
35
36
# File 'lib/http_stub/models/response.rb', line 34

def delay_in_seconds
  @response_options["delay_in_seconds"]
end

#empty?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/http_stub/models/response.rb', line 42

def empty?
  @original_options.empty?
end

#headersObject



38
39
40
# File 'lib/http_stub/models/response.rb', line 38

def headers
  {"content-type" => @response_options["content_type"]}
end

#statusObject



26
27
28
# File 'lib/http_stub/models/response.rb', line 26

def status
  @response_options["status"]
end