Class: WireMockMapper::ResponseBuilder
- Inherits:
-
Object
- Object
- WireMockMapper::ResponseBuilder
- Defined in:
- lib/response_builder.rb
Instance Method Summary collapse
-
#initialize ⇒ ResponseBuilder
constructor
A new instance of ResponseBuilder.
- #to_hash ⇒ Object
- #to_json ⇒ Object
-
#with_body(value) ⇒ ResponseBuilder
Response body.
-
#with_header(key, value) ⇒ ResponseBuilder
Add a response header.
-
#with_status(status_code) ⇒ ResponseBuilder
Add a response http status.
-
#with_status_message(status_message) ⇒ ResponseBuilder
Add a response http status.
Constructor Details
#initialize ⇒ ResponseBuilder
Returns a new instance of ResponseBuilder.
3 4 5 |
# File 'lib/response_builder.rb', line 3 def initialize @options = {} end |
Instance Method Details
#to_hash ⇒ Object
42 43 44 |
# File 'lib/response_builder.rb', line 42 def to_hash(*) @options end |
#to_json ⇒ Object
46 47 48 |
# File 'lib/response_builder.rb', line 46 def to_json(*) @options.to_json end |
#with_body(value) ⇒ ResponseBuilder
Response body
10 11 12 13 14 |
# File 'lib/response_builder.rb', line 10 def with_body(value) value = value.to_json unless value.is_a? String @options[:body] = value self end |
#with_header(key, value) ⇒ ResponseBuilder
Add a response header
20 21 22 23 24 |
# File 'lib/response_builder.rb', line 20 def with_header(key, value) @options[:headers] ||= {} @options[:headers][key] = value self end |
#with_status(status_code) ⇒ ResponseBuilder
Add a response http status
29 30 31 32 |
# File 'lib/response_builder.rb', line 29 def with_status(status_code) @options[:status] = status_code self end |
#with_status_message(status_message) ⇒ ResponseBuilder
Add a response http status
37 38 39 40 |
# File 'lib/response_builder.rb', line 37 def () @options[:statusMessage] = self end |