Class: PactBroker::Webhooks::Status

Inherits:
Object
  • Object
show all
Defined in:
lib/pact_broker/webhooks/status.rb

Instance Method Summary collapse

Constructor Details

#initialize(pact, webhooks, latest_triggered_webhooks) ⇒ Status

Returns a new instance of Status.



5
6
7
8
# File 'lib/pact_broker/webhooks/status.rb', line 5

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

Instance Method Details

#to_sObject



10
11
12
# File 'lib/pact_broker/webhooks/status.rb', line 10

def to_s
  to_sym.to_s
end

#to_symObject



14
15
16
17
18
19
20
21
# File 'lib/pact_broker/webhooks/status.rb', line 14

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