Sha256: 4814b84b8d20520595d0cf64cf7f85e7611d8363851da363a96136763d3bd2e3

Contents?: true

Size: 682 Bytes

Versions: 3

Compression:

Stored size: 682 Bytes

Contents

module PactBroker
  module Webhooks
    class Status

      def initialize pact, webhooks, latest_triggered_webhooks
        @webhooks = webhooks
        @latest_triggered_webhooks = latest_triggered_webhooks
      end

      def to_s
        to_sym.to_s
      end

      def to_sym
        return :none if webhooks.empty?
        return :not_run if latest_triggered_webhooks.empty?
        if latest_triggered_webhooks.any?{|w| w.status == "retrying" }
          return :retrying
        end
        latest_triggered_webhooks.all?{|w| w.status == "success"} ? :success : :failure
      end

      private

      attr_reader :webhooks, :latest_triggered_webhooks

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pact_broker-2.6.0 lib/pact_broker/webhooks/status.rb
pact_broker-2.5.1 lib/pact_broker/webhooks/status.rb
pact_broker-2.5.0 lib/pact_broker/webhooks/status.rb