Sha256: 5da8dad88d48ed659b43ed15d3a5c3982850f82bfb67f0de715db926b675aef9

Contents?: true

Size: 1.88 KB

Versions: 17

Compression:

Stored size: 1.88 KB

Contents

require "pact_broker/hash_refinements"

module PactBroker
  module Matrix
    class UnresolvedSelector < Hash
      using PactBroker::HashRefinements

      def initialize(params = {})
        merge!(params)
      end

      def self.from_hash(hash)
        new(hash.symbolize_keys.snakecase_keys.slice(:pacticipant_name, :pacticipant_version_number, :latest, :tag, :branch, :environment_name))
      end

      def pacticipant_name
        self[:pacticipant_name]
      end

      def pacticipant_version_number
        self[:pacticipant_version_number]
      end

      def latest?
        !!latest
      end

      def overall_latest?
        latest? && !tag && !branch
      end

      def latest
        self[:latest]
      end

      def tag
        self[:tag]
      end

      def branch
        self[:branch]
      end

      def environment_name
        self[:environment_name]
      end

      def latest= latest
        self[:latest] = latest
      end

      def tag= tag
        self[:tag] = tag
      end

      def branch= branch
        self[:branch] = branch
      end

      def environment_name= environment_name
        self[:environment_name] = environment_name
      end

      def pacticipant_name= pacticipant_name
        self[:pacticipant_name] = pacticipant_name
      end

      def pacticipant_version_number= pacticipant_version_number
        self[:pacticipant_version_number] = pacticipant_version_number
      end

      # TODO delete this once docker image uses new selector class for clean
      def max_age= max_age
        self[:max_age] = max_age
      end

      def max_age
        self[:max_age]
      end

      def all_for_pacticipant?
        !!pacticipant_name && !pacticipant_version_number && !tag && !branch && !latest && !environment_name && !max_age
      end

      def latest_for_pacticipant_and_tag?
        !!(pacticipant_name && tag && latest)
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
pact_broker-2.93.4 lib/pact_broker/matrix/unresolved_selector.rb
pact_broker-2.93.3 lib/pact_broker/matrix/unresolved_selector.rb
pact_broker-2.93.2 lib/pact_broker/matrix/unresolved_selector.rb
pact_broker-2.93.1 lib/pact_broker/matrix/unresolved_selector.rb
pact_broker-2.93.0 lib/pact_broker/matrix/unresolved_selector.rb
pact_broker-2.92.0 lib/pact_broker/matrix/unresolved_selector.rb
pact_broker-2.91.0 lib/pact_broker/matrix/unresolved_selector.rb
pact_broker-2.90.0 lib/pact_broker/matrix/unresolved_selector.rb
pact_broker-2.89.1 lib/pact_broker/matrix/unresolved_selector.rb
pact_broker-2.89.0 lib/pact_broker/matrix/unresolved_selector.rb
pact_broker-2.88.0 lib/pact_broker/matrix/unresolved_selector.rb
pact_broker-2.87.0 lib/pact_broker/matrix/unresolved_selector.rb
pact_broker-2.86.0 lib/pact_broker/matrix/unresolved_selector.rb
pact_broker-2.85.1 lib/pact_broker/matrix/unresolved_selector.rb
pact_broker-2.85.0 lib/pact_broker/matrix/unresolved_selector.rb
pact_broker-2.84.0 lib/pact_broker/matrix/unresolved_selector.rb
pact_broker-2.83.0 lib/pact_broker/matrix/unresolved_selector.rb