lib/pact_broker/pacts/selector.rb in pact_broker-2.73.0 vs lib/pact_broker/pacts/selector.rb in pact_broker-2.74.0

- old
+ new

@@ -3,10 +3,14 @@ class Selector < Hash def initialize(options = {}) merge!(options) end + def resolve(consumer_version) + ResolvedSelector.new(self.to_h, consumer_version) + end + def tag= tag self[:tag] = tag end def latest= latest @@ -92,10 +96,14 @@ def all_for_tag? !!(tag && !latest?) end + def == other + other.class == self.class && super + end + def <=> other if overall_latest? || other.overall_latest? if overall_latest? == other.overall_latest? 0 else @@ -120,9 +128,23 @@ private def latest? !!self[:latest] + end + end + + class ResolvedSelector < Selector + def initialize(options = {}, consumer_version) + super(options.merge(consumer_version: consumer_version)) + end + + def consumer_version + self[:consumer_version] + end + + def == other + super && consumer_version == other.consumer_version end end end end