class PactBroker::Api::Resources::LatestPact

Public Instance Methods

allowed_methods() click to toggle source
# File lib/pact_broker/api/resources/latest_pact.rb, line 19
def allowed_methods
  ["GET", "OPTIONS"]
end
content_types_provided() click to toggle source
# File lib/pact_broker/api/resources/latest_pact.rb, line 10
def content_types_provided
  [
    ["application/hal+json", :to_json],
    ["application/json", :to_json],
    ["text/html", :to_html],
    ["application/vnd.pactbrokerextended.v1+json", :to_extended_json]
  ]
end
metadata() click to toggle source
# File lib/pact_broker/api/resources/latest_pact.rb, line 52
def metadata
  @metadata ||= encode_metadata(PactBroker::Pacts::Metadata.build_metadata_for_latest_pact(pact, identifier_from_path))
end
pact() click to toggle source
# File lib/pact_broker/api/resources/latest_pact.rb, line 48
def pact
  @pact ||= pact_service.find_latest_pact(identifier_from_path)
end
policy_name() click to toggle source
# File lib/pact_broker/api/resources/latest_pact.rb, line 27
def policy_name
  :'pacts::pact'
end
resource_exists?() click to toggle source
# File lib/pact_broker/api/resources/latest_pact.rb, line 23
def resource_exists?
  !!pact
end
to_extended_json() click to toggle source
# File lib/pact_broker/api/resources/latest_pact.rb, line 36
def to_extended_json
  decorator_class(:extended_pact_decorator).new(pact).to_json(decorator_options(metadata: metadata))
end
to_html() click to toggle source
# File lib/pact_broker/api/resources/latest_pact.rb, line 40
def to_html
  PactBroker.configuration.html_pact_renderer.call(
    pact, {
      base_url: ui_base_url,
      badge_url: "#{resource_url}/badge.svg"
  })
end
to_json() click to toggle source
# File lib/pact_broker/api/resources/latest_pact.rb, line 31
def to_json
  response.headers["X-Pact-Consumer-Version"] = pact.consumer_version_number
  decorator_class(:pact_decorator).new(pact).to_json(decorator_options(metadata: metadata))
end