Class: PactBroker::Pacts::PactPublication

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/pact_broker/pacts/pact_publication.rb

Instance Method Summary collapse

Instance Method Details

#before_createObject



112
113
114
115
# File 'lib/pact_broker/pacts/pact_publication.rb', line 112

def before_create
  super
  self.revision_number ||= 1
end

#consumer_version_tagsObject



123
124
125
# File 'lib/pact_broker/pacts/pact_publication.rb', line 123

def consumer_version_tags
  consumer_version.tags
end

#head_tag_namesObject

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)



119
120
121
# File 'lib/pact_broker/pacts/pact_publication.rb', line 119

def head_tag_names
  @head_tag_names ||= PactBroker::Domain::Tag.head_tags_for_pact_publication(self).collect(&:name)
end

#latest_verificationObject



127
128
129
# File 'lib/pact_broker/pacts/pact_publication.rb', line 127

def latest_verification
  pact_version.latest_verification
end

#to_domainObject



131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/pact_broker/pacts/pact_publication.rb', line 131

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_lightweightObject



148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/pact_broker/pacts/pact_publication.rb', line 148

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_domainObject



162
163
164
# File 'lib/pact_broker/pacts/pact_publication.rb', line 162

def to_version_domain
  OpenStruct.new(number: consumer_version.number, pacticipant: consumer, tags: consumer_version.tags, order: consumer_version.order)
end

#to_version_domain_lightweightObject



166
167
168
# File 'lib/pact_broker/pacts/pact_publication.rb', line 166

def to_version_domain_lightweight
  OpenStruct.new(number: consumer_version.number, pacticipant: consumer, order: consumer_version.order)
end