Class: PactBroker::Versions::BranchVersion

Inherits:
Object
  • Object
show all
Defined in:
lib/pact_broker/versions/branch_version.rb

Instance Method Summary collapse

Instance Method Details

#before_saveObject



20
21
22
23
24
25
# 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

#latest?Boolean

Returns:

  • (Boolean)


27
28
29
30
# 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?Boolean

For Pactflow

Returns:

  • (Boolean)


41
42
43
# File 'lib/pact_broker/versions/branch_version.rb', line 41

def main_branch?
  branch_name == branch.pacticipant.main_branch
end

#number_of_versions_from_headObject

For Pactflow



46
47
48
# 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

#pacticipantObject



36
37
38
# File 'lib/pact_broker/versions/branch_version.rb', line 36

def pacticipant
  branch.pacticipant
end

#version_numberObject



32
33
34
# File 'lib/pact_broker/versions/branch_version.rb', line 32

def version_number
  version.number
end