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



265
266
267
268
269
# File 'lib/pact_broker/domain/version.rb', line 265

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

#before_destroyObject



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

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



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

def branch_names
  branch_versions.collect(&:branch_name)
end

#branch_version_for_branch(branch) ⇒ Object



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

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



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

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

#head_tagsObject



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

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

#latest_for_branch?Boolean

Returns:

  • (Boolean)


295
296
297
# File 'lib/pact_broker/domain/version.rb', line 295

def latest_for_branch?
  branch_heads.any?
end

#latest_for_pacticipant?Boolean

Returns:

  • (Boolean)


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

def latest_for_pacticipant?
  latest_version_for_pacticipant == self
end

#latest_pact_publicationObject

What about provider??? This makes no sense



291
292
293
# File 'lib/pact_broker/domain/version.rb', line 291

def latest_pact_publication
  pact_publications.last
end

#tag_namesObject



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

def tag_names
  tags.collect(&:name)
end

#to_sObject



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

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

#version_and_updated_dateObject



282
283
284
# File 'lib/pact_broker/domain/version.rb', line 282

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