Class: Pact::ConsumerContractDecorator

Inherits:
Object
  • Object
show all
Includes:
ActiveSupportSupport
Defined in:
lib/pact/consumer_contract/consumer_contract_decorator.rb

Instance Method Summary collapse

Constructor Details

#initialize(consumer_contract, decorator_options = {}) ⇒ ConsumerContractDecorator

Returns a new instance of ConsumerContractDecorator.



9
10
11
12
# File 'lib/pact/consumer_contract/consumer_contract_decorator.rb', line 9

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

Instance Method Details

#as_json(options = {}) ⇒ Object



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

def as_json(options = {})
  fix_all_the_things(
    consumer: consumer_contract.consumer.as_json,
    provider: consumer_contract.provider.as_json,
    interactions: sorted_interactions.collect{ |i| InteractionDecorator.new(i, @decorator_options).as_json},
    metadata: {
      pactSpecification: {
        version: pact_specification_version
      }
    }
  )
end

#to_json(options = {}) ⇒ Object



27
28
29
# File 'lib/pact/consumer_contract/consumer_contract_decorator.rb', line 27

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