Class: Pact::MockService::ResponseDecorator
- Inherits:
-
Object
- Object
- Pact::MockService::ResponseDecorator
- Defined in:
- lib/pact/mock_service/response_decorator.rb
Instance Method Summary collapse
- #as_json(options = {}) ⇒ Object
-
#initialize(response) ⇒ ResponseDecorator
constructor
A new instance of ResponseDecorator.
- #to_hash ⇒ Object
- #to_json(options = {}) ⇒ Object
Constructor Details
#initialize(response) ⇒ ResponseDecorator
Returns a new instance of ResponseDecorator.
5 6 7 |
# File 'lib/pact/mock_service/response_decorator.rb', line 5 def initialize response @response = response end |
Instance Method Details
#as_json(options = {}) ⇒ Object
13 14 15 |
# File 'lib/pact/mock_service/response_decorator.rb', line 13 def as_json = {} to_hash end |
#to_hash ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/pact/mock_service/response_decorator.rb', line 17 def to_hash hash = {} hash[:status] = response.status if response.specified?(:status) hash[:headers] = response.headers if response.specified?(:headers) hash[:body] = response.body if response.specified?(:body) hash end |
#to_json(options = {}) ⇒ Object
9 10 11 |
# File 'lib/pact/mock_service/response_decorator.rb', line 9 def to_json( = {}) as_json.to_json() end |