Sha256: 433eade2c49052ae65c56bf8a5ee8082567ee1faff7aa12e00d8d3dae32ce293

Contents?: true

Size: 1.14 KB

Versions: 28

Compression:

Stored size: 1.14 KB

Contents

module Pact
   module Consumer

      #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

      class DistinctInteractionsFilter < InteractionsFilter

         def << interaction
            if (ndx = index_of(interaction))
               if @interactions[ndx] != interaction
                  raise "Interaction with same description (#{interaction.description}) and provider state (#{interaction.provider_state}) already exists"
               end
            else
               @interactions << interaction
            end
         end
      end

   end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
pact-1.0.30 lib/pact/consumer/interactions_filter.rb
pact-1.0.29 lib/pact/consumer/interactions_filter.rb
pact-1.0.28 lib/pact/consumer/interactions_filter.rb
pact-1.0.27 lib/pact/consumer/interactions_filter.rb
pact-1.0.26 lib/pact/consumer/interactions_filter.rb
pact-1.0.25 lib/pact/consumer/interactions_filter.rb
pact-1.0.24 lib/pact/consumer/interactions_filter.rb
pact-1.0.23 lib/pact/consumer/interactions_filter.rb
pact-1.0.22 lib/pact/consumer/interactions_filter.rb
pact-1.0.21 lib/pact/consumer/interactions_filter.rb
pact-1.0.20 lib/pact/consumer/interactions_filter.rb
pact-1.0.19 lib/pact/consumer/interactions_filter.rb
pact-1.0.18 lib/pact/consumer/interactions_filter.rb
pact-1.0.15 lib/pact/consumer/interactions_filter.rb
pact-1.0.13 lib/pact/consumer/interactions_filter.rb
pact-1.0.12 lib/pact/consumer/interactions_filter.rb
pact-1.0.11 lib/pact/consumer/interactions_filter.rb
pact-1.0.10 lib/pact/consumer/interactions_filter.rb
pact-1.0.9 lib/pact/consumer/interactions_filter.rb
pact-1.0.8 lib/pact/consumer/interactions_filter.rb