Class: PactBroker::Pacts::PactPublication
- Inherits:
-
Object
- Object
- PactBroker::Pacts::PactPublication
- Extended by:
- Forwardable
- Defined in:
- lib/pact_broker/pacts/pact_publication.rb
Constant Summary collapse
- UNIQUE_CONSTRAINT_KEYS =
[:consumer_version_id, :provider_id, :revision_number].freeze
Instance Method Summary collapse
- #before_create ⇒ Object
- #consumer_version_tags ⇒ Object
-
#head_tag_names ⇒ Object
The names of the tags for which this pact is the latest pact with that tag (ie. it is not necessarily the pact for the latest consumer version with the given tag).
- #latest_verification ⇒ Object
- #to_domain ⇒ Object
- #to_version_domain ⇒ Object
- #upsert ⇒ Object
Instance Method Details
#before_create ⇒ Object
29 30 31 32 |
# File 'lib/pact_broker/pacts/pact_publication.rb', line 29 def before_create super self.revision_number ||= 1 end |
#consumer_version_tags ⇒ Object
40 41 42 |
# File 'lib/pact_broker/pacts/pact_publication.rb', line 40 def consumer_version. end |
#head_tag_names ⇒ Object
The names of the tags for which this pact is the latest pact with that tag (ie. it is not necessarily the pact for the latest consumer version with the given tag)
36 37 38 |
# File 'lib/pact_broker/pacts/pact_publication.rb', line 36 def head_tag_names LatestTaggedPactPublications.where(id: id).select(:tag_name).collect{|t| t[:tag_name]} end |
#latest_verification ⇒ Object
44 45 46 |
# File 'lib/pact_broker/pacts/pact_publication.rb', line 44 def latest_verification pact_version.latest_verification end |
#to_domain ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/pact_broker/pacts/pact_publication.rb', line 48 def to_domain PactBroker::Domain::Pact.new( id: id, provider: provider, consumer: consumer_version.pacticipant, consumer_version_number: consumer_version.number, consumer_version: to_version_domain, revision_number: revision_number, json_content: pact_version.content, pact_version_sha: pact_version.sha, latest_verification: latest_verification, created_at: created_at, head_tag_names: head_tag_names, db_model: self ) end |
#to_version_domain ⇒ Object
65 66 67 |
# File 'lib/pact_broker/pacts/pact_publication.rb', line 65 def to_version_domain OpenStruct.new(number: consumer_version.number, pacticipant: consumer_version.pacticipant, tags: consumer_version., order: consumer_version.order) end |
#upsert ⇒ Object
69 70 71 72 73 |
# File 'lib/pact_broker/pacts/pact_publication.rb', line 69 def upsert params = to_hash.merge(created_at: Sequel.datetime_class.now) self.id = PactPublication.upsert(params, UNIQUE_CONSTRAINT_KEYS).id self.refresh end |