Class: PactBroker::Domain::Pacticipant
Constant Summary
collapse
- BATCH_DELETE_SIZE =
500
Instance Method Summary
collapse
call, #generate_display_name
Methods included from Messages
#message, #pluralize, #validation_message, #validation_message_at_index
Instance Method Details
#any_versions? ⇒ Boolean
84
85
86
|
# File 'lib/pact_broker/domain/pacticipant.rb', line 84
def any_versions?
PactBroker::Domain::Version.where(pacticipant: self).any?
end
|
#before_save ⇒ Object
74
75
76
77
78
|
# File 'lib/pact_broker/domain/pacticipant.rb', line 74
def before_save
super
self.display_name = generate_display_name(name) if display_name.blank?
self.main_branch = nil if main_branch.blank?
end
|
#branch_head_for(branch_name) ⇒ Object
88
89
90
|
# File 'lib/pact_broker/domain/pacticipant.rb', line 88
def branch_head_for(branch_name)
branch_heads.find{ | branch_head | branch_head.branch_name == branch_name }
end
|
#delete_pact_versions_in_batches ⇒ Object
64
65
66
67
68
69
70
71
72
|
# File 'lib/pact_broker/domain/pacticipant.rb', line 64
def delete_pact_versions_in_batches
dataset = PactBroker::Pacts::PactVersion.where(consumer: self).or(provider: self).order(:id)
loop do
deleted = PactBroker::Pacts::PactVersion
.where(id: dataset.limit(BATCH_DELETE_SIZE).select(:id))
.delete
break if deleted.zero?
end
end
|
#label?(name) ⇒ Boolean
92
93
94
|
# File 'lib/pact_broker/domain/pacticipant.rb', line 92
def label?(name)
labels.any? { |label| label.name == name }
end
|
#to_s ⇒ Object
80
81
82
|
# File 'lib/pact_broker/domain/pacticipant.rb', line 80
def to_s
"Pacticipant: id=#{id}, name=#{name}"
end
|