Sha256: 23156cbf746763a47e768ea5f21b1e39f0d902b40b9624fceae71c98c6937aad

Contents?: true

Size: 1.13 KB

Versions: 32

Compression:

Stored size: 1.13 KB

Contents

#
# When running in pactfile_write_mode :overwrite, all interactions are cleared from the
# pact file, and all new interactions should be distinct (unique description and provider state).
# When running in pactfile_write_mode :update, an interaction with the same description
# and provider state as an existing one will just overwrite that one interaction.
#

module Pact
   module MockService
      module Interactions

         #TODO: think of a better word than filter
         class InteractionsFilter
            def initialize interactions = []
               @interactions = interactions
            end

            def index_of interaction
               @interactions.find_index{ |i| i.matches_criteria?(description: interaction.description, provider_state: interaction.provider_state)}
            end
         end

         class UpdatableInteractionsFilter < InteractionsFilter
            def << interaction
               if (ndx = index_of(interaction))
                  @interactions[ndx] = interaction
               else
                  @interactions << interaction
               end
            end
         end
      end
   end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
pact-mock_service-0.7.0 lib/pact/mock_service/interactions/interactions_filter.rb
pact-mock_service-0.6.0 lib/pact/mock_service/interactions/interactions_filter.rb
pact-mock_service-0.5.5 lib/pact/mock_service/interactions/interactions_filter.rb
pact-mock_service-0.5.4 lib/pact/mock_service/interactions/interactions_filter.rb
pact-mock_service-0.5.3 lib/pact/mock_service/interactions/interactions_filter.rb
pact-mock_service-0.5.2 lib/pact/mock_service/interactions/interactions_filter.rb
pact-mock_service-0.5.1 lib/pact/mock_service/interactions/interactions_filter.rb
pact-mock_service-0.5.0 lib/pact/mock_service/interactions/interactions_filter.rb
pact-mock_service-0.4.2 lib/pact/mock_service/interactions/interactions_filter.rb
pact-mock_service-0.4.1 lib/pact/mock_service/interactions/interactions_filter.rb
pact-mock_service-0.4.0 lib/pact/mock_service/interactions/interactions_filter.rb
pact-mock_service-0.3.0 lib/pact/mock_service/interactions/interactions_filter.rb