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
34 35 36 37 |
# File 'lib/pact_broker/pacts/pact_publication.rb', line 34 def before_create super self.revision_number ||= 1 end |
#consumer_version_tags ⇒ Object
45 46 47 |
# File 'lib/pact_broker/pacts/pact_publication.rb', line 45 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)
41 42 43 |
# File 'lib/pact_broker/pacts/pact_publication.rb', line 41 def head_tag_names LatestTaggedPactPublications.where(id: id).select(:tag_name).collect{|t| t[:tag_name]} end |
#latest_verification ⇒ Object
49 50 51 |
# File 'lib/pact_broker/pacts/pact_publication.rb', line 49 def latest_verification pact_version.latest_verification end |
#to_domain ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/pact_broker/pacts/pact_publication.rb', line 53 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: nil, created_at: created_at, head_tag_names: [], db_model: self ) end |
#to_domain_lightweight ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/pact_broker/pacts/pact_publication.rb', line 70 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
84 85 86 |
# File 'lib/pact_broker/pacts/pact_publication.rb', line 84 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
88 89 90 |
# File 'lib/pact_broker/pacts/pact_publication.rb', line 88 def to_version_domain_lightweight OpenStruct.new(number: consumer_version.number, pacticipant: consumer, order: consumer_version.order) end |
#upsert ⇒ Object
92 93 94 95 96 |
# File 'lib/pact_broker/pacts/pact_publication.rb', line 92 def upsert params = to_hash.merge(created_at: Sequel.datetime_class.now) self.id = PactPublication.upsert(params, UNIQUE_CONSTRAINT_KEYS).id self.refresh end |