Class: PactBroker::Domain::Version

Inherits:
Object
  • Object
show all
Defined in:
lib/pact_broker/domain/version.rb

Instance Method Summary collapse

Instance Method Details

#after_createObject

Isn’t called on upsert when the record is updated with Sqlite Is called with Postgres/MySQL Haven’t had time to dig into why



272
273
274
275
276
# File 'lib/pact_broker/domain/version.rb', line 272

def after_create
  super
  OrderVersions.(self) unless self.order
  refresh
end

#before_destroyObject



278
279
280
281
282
283
# File 'lib/pact_broker/domain/version.rb', line 278

def before_destroy
  PactBroker::Deployments::DeployedVersion.where(version: self).destroy
  PactBroker::Deployments::ReleasedVersion.where(version: self).destroy
  PactBroker::Domain::Tag.where(version: self).destroy
  super
end

#branch_namesObject



318
319
320
# File 'lib/pact_broker/domain/version.rb', line 318

def branch_names
  branch_versions.collect(&:branch_name)
end

#branch_version_for_branch(branch) ⇒ Object



310
311
312
# File 'lib/pact_broker/domain/version.rb', line 310

def branch_version_for_branch(branch)
  branch_versions.find { | branch_version | branch_version.branch_id == branch.id }
end

#branch_version_for_branch_name(branch_name) ⇒ Object



314
315
316
# File 'lib/pact_broker/domain/version.rb', line 314

def branch_version_for_branch_name(branch_name)
  branch_versions.find { | branch_version | branch_version.branch_name == branch_name }
end

#head_tagsObject



293
294
295
# File 'lib/pact_broker/domain/version.rb', line 293

def head_tags
  tags.select(&:latest_for_pacticipant?)
end

#latest_for_branch?Boolean

Returns:

  • (Boolean)


302
303
304
# File 'lib/pact_broker/domain/version.rb', line 302

def latest_for_branch?
  branch_heads.any?
end

#latest_for_pacticipant?Boolean

Returns:

  • (Boolean)


306
307
308
# File 'lib/pact_broker/domain/version.rb', line 306

def latest_for_pacticipant?
  latest_version_for_pacticipant == self
end

#latest_pact_publicationObject

What about provider??? This makes no sense



298
299
300
# File 'lib/pact_broker/domain/version.rb', line 298

def latest_pact_publication
  pact_publications.last
end

#tag_namesObject



322
323
324
# File 'lib/pact_broker/domain/version.rb', line 322

def tag_names
  tags.collect(&:name)
end

#to_sObject



285
286
287
# File 'lib/pact_broker/domain/version.rb', line 285

def to_s
  "Version: number=#{number}, pacticipant=#{pacticipant_id}"
end

#version_and_updated_dateObject



289
290
291
# File 'lib/pact_broker/domain/version.rb', line 289

def version_and_updated_date
  "Version #{number} - #{updated_at.to_time.localtime.strftime("%d/%m/%Y")}"
end