Class: Pact::RequestDecorator

Inherits:
Object
  • Object
show all
Defined in:
lib/pact/consumer_contract/request_decorator.rb

Instance Method Summary collapse

Constructor Details

#initialize(request, decorator_options = {}) ⇒ RequestDecorator

Returns a new instance of RequestDecorator.



6
7
8
9
# File 'lib/pact/consumer_contract/request_decorator.rb', line 6

def initialize request, decorator_options = {}
  @request = request
  @decorator_options = decorator_options
end

Instance Method Details

#as_json(options = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/pact/consumer_contract/request_decorator.rb', line 15

def as_json options = {}
  hash = {
    method: request.method,
    path: path
  }
  hash[:query]   = query   if request.specified?(:query)
  hash[:headers] = headers if request.specified?(:headers)
  hash[:body]    = body    if request.specified?(:body)
  hash
end

#to_json(options = {}) ⇒ Object



11
12
13
# File 'lib/pact/consumer_contract/request_decorator.rb', line 11

def to_json(options = {})
  as_json.to_json(options)
end