Class: PactBroker::Domain::Pacticipant

Inherits:
Sequel::Model
  • Object
show all
Includes:
Messages
Defined in:
lib/pact_broker/domain/pacticipant.rb

Instance Method Summary collapse

Methods included from Messages

#message, #potential_duplicate_pacticipant_message, #validation_message

Instance Method Details

#any_versions?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/pact_broker/domain/pacticipant.rb', line 59

def any_versions?
  PactBroker::Domain::Version.where(pacticipant: self).any?
end

#before_destroyObject



36
37
38
39
40
41
42
43
# File 'lib/pact_broker/domain/pacticipant.rb', line 36

def before_destroy
  PactBroker::Pacts::PactPublication.where(provider: self).delete
  PactBroker::Domain::Verification.where(consumer: self).or(provider: self).delete
  PactBroker::Domain::Version.where(pacticipant: self).delete
  PactBroker::Pacts::PactVersion.where(consumer: self).or(provider: self).delete
  PactBroker::Domain::Label.where(pacticipant: self).destroy
  super
end

#latest_versionObject



45
46
47
# File 'lib/pact_broker/domain/pacticipant.rb', line 45

def latest_version
  versions.last
end

#to_sObject



49
50
51
# File 'lib/pact_broker/domain/pacticipant.rb', line 49

def to_s
  "Pacticipant: id=#{id}, name=#{name}"
end

#validateObject



53
54
55
56
57
# File 'lib/pact_broker/domain/pacticipant.rb', line 53

def validate
  messages = []
  messages << message('errors.validation.attribute_missing', attribute: 'name') unless name
  messages
end