Sha256: 70626b4c99660d1dc15feba9c051cba3f2f79e0d6702bc00c3ec483c8d1d8aa7

Contents?: true

Size: 1.32 KB

Versions: 2

Compression:

Stored size: 1.32 KB

Contents

require_relative 'base_decorator'
require 'pact_broker/api/pact_broker_urls'
require 'delegate'
require 'pact_broker/pacts/verifiable_pact_messages'

module PactBroker
  module Api
    module Decorators
      class VerifiablePactDecorator < BaseDecorator

        # Allows a "flat" VerifiablePact to look like it has
        # a nested verification_properties object for Reform
        class Reshaper < SimpleDelegator
          def verification_properties
            __getobj__()
          end
        end

        def initialize(verifiable_pact)
          super(Reshaper.new(verifiable_pact))
        end

        property :verification_properties, as: :verificationProperties do
          property :pending
          property :pending_reason, as: :pendingReason, exec_context: :decorator
          property :inclusion_reason, as: :inclusionReason, exec_context: :decorator

          def inclusion_reason
            PactBroker::Pacts::VerifiablePactMessages.new(represented).inclusion_reason
          end

          def pending_reason
            PactBroker::Pacts::VerifiablePactMessages.new(represented).pending_reason
          end
        end

        link :self do | context |
          {
            href: pact_version_url(represented, context[:base_url]),
            name: represented.name
          }
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pact_broker-2.40.0 lib/pact_broker/api/decorators/verifiable_pact_decorator.rb
pact_broker-2.39.0 lib/pact_broker/api/decorators/verifiable_pact_decorator.rb