Sha256: 3aef569f311ad0c5b239e8663a6f4c6c931e3d4e589d0d3a6922dbd97700dd0f

Contents?: true

Size: 944 Bytes

Versions: 125

Compression:

Stored size: 944 Bytes

Contents

module Pact
  module Provider::State
    class ProviderStateProxy

      attr_reader :missing_provider_states

      def initialize
        @missing_provider_states = {}
      end

      def get name, options = {}
        unless provider_state = ProviderStates.get(name, options)
          register_missing_provider_state name, options[:for]
          raise error_message name, options[:for]
        end
        provider_state
      end

      def get_base options = {}
        ProviderStates.get_base options
      end

      private

      def error_message name, consumer
        "Could not find provider state \"#{name}\" for consumer #{consumer}"
      end

      def register_missing_provider_state name, consumer
        missing_states_for(consumer) << name unless missing_states_for(consumer).include?(name)
      end

      def missing_states_for consumer
        @missing_provider_states[consumer] ||= []
      end

    end
  end
end

Version data entries

125 entries across 125 versions & 1 rubygems

Version Path
pact-1.0.38 lib/pact/provider/state/provider_state_proxy.rb
pact-1.1.0.rc1 lib/pact/provider/state/provider_state_proxy.rb
pact-1.0.37 lib/pact/provider/state/provider_state_proxy.rb
pact-1.0.36 lib/pact/provider/state/provider_state_proxy.rb
pact-1.0.35 lib/pact/provider/state/provider_state_proxy.rb