class PactBroker::Versions::BranchVersion
Public Instance Methods
before_save()
click to toggle source
Calls superclass method
# File lib/pact_broker/versions/branch_version.rb, line 20 def before_save super self.version_order = version.order self.pacticipant_id = version.pacticipant_id self.branch_name = branch.name end
find_latest_for_branch(branch)
click to toggle source
# File lib/pact_broker/versions/branch_version.rb, line 14 def find_latest_for_branch(branch) max_version_order = BranchVersion.select(Sequel.function(:max, :version_order)).where(branch_id: branch.id) BranchVersion.where(branch_id: branch.id, version_order: max_version_order).single_record end
latest?()
click to toggle source
# File lib/pact_broker/versions/branch_version.rb, line 27 def latest? # Should not be possible, not to have a branch head, but have seen this error in the logs branch_head&.branch_version_id == id end
main_branch?()
click to toggle source
For Pactflow
# File lib/pact_broker/versions/branch_version.rb, line 41 def main_branch? branch_name == branch.pacticipant.main_branch end
number_of_versions_from_head()
click to toggle source
For Pactflow
# File lib/pact_broker/versions/branch_version.rb, line 46 def number_of_versions_from_head @number_of_versions_from_head ||= BranchVersion.where(branch_id: branch_id).where(Sequel.lit("version_order > ?", version_order) ).count end
pacticipant()
click to toggle source
# File lib/pact_broker/versions/branch_version.rb, line 36 def pacticipant branch.pacticipant end
version_number()
click to toggle source
# File lib/pact_broker/versions/branch_version.rb, line 32 def version_number version.number end