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_domain_lightweight ⇒ Object
- #to_version_domain ⇒ Object
- #to_version_domain_lightweight ⇒ Object
- #upsert ⇒ Object
Instance Method Details
#before_create ⇒ Object
95 96 97 98 |
# File 'lib/pact_broker/pacts/pact_publication.rb', line 95 def before_create super self.revision_number ||= 1 end |
#consumer_version_tags ⇒ Object
106 107 108 |
# File 'lib/pact_broker/pacts/pact_publication.rb', line 106 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)
102 103 104 |
# File 'lib/pact_broker/pacts/pact_publication.rb', line 102 def head_tag_names LatestTaggedPactPublications.where(id: id).select(:tag_name).collect{|t| t[:tag_name]} end |
#latest_verification ⇒ Object
110 111 112 |
# File 'lib/pact_broker/pacts/pact_publication.rb', line 110 def latest_verification pact_version.latest_verification end |
#to_domain ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/pact_broker/pacts/pact_publication.rb', line 114 def to_domain PactBroker::Domain::Pact.new( id: id, provider: provider, consumer: consumer, 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: pact_version.latest_verification, created_at: created_at, head_tag_names: [], db_model: self ) end |
#to_domain_lightweight ⇒ Object
131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/pact_broker/pacts/pact_publication.rb', line 131 def to_domain_lightweight PactBroker::Domain::Pact.new( id: id, provider: provider, consumer: consumer, consumer_version_number: consumer_version.number, consumer_version: to_version_domain_lightweight, revision_number: revision_number, pact_version_sha: pact_version.sha, created_at: created_at, db_model: self ) end |
#to_version_domain ⇒ Object
145 146 147 |
# File 'lib/pact_broker/pacts/pact_publication.rb', line 145 def to_version_domain OpenStruct.new(number: consumer_version.number, pacticipant: consumer, tags: consumer_version., order: consumer_version.order) end |
#to_version_domain_lightweight ⇒ Object
149 150 151 |
# File 'lib/pact_broker/pacts/pact_publication.rb', line 149 def to_version_domain_lightweight OpenStruct.new(number: consumer_version.number, pacticipant: consumer, order: consumer_version.order) end |
#upsert ⇒ Object
153 154 155 156 157 |
# File 'lib/pact_broker/pacts/pact_publication.rb', line 153 def upsert params = to_hash.merge(created_at: Sequel.datetime_class.now) self.id = PactPublication.upsert(params, UNIQUE_CONSTRAINT_KEYS).id self.refresh end |