Sha256: 418645b81d6cd70d4e5fb7b772f47d19032d8f78a3115f9d7bc69f9ecba90f56

Contents?: true

Size: 927 Bytes

Versions: 16

Compression:

Stored size: 927 Bytes

Contents

require 'pact_broker/api/resources/base_resource'
require 'pact_broker/configuration'

module PactBroker
  module Api
    module Resources

      class LatestPact < BaseResource

        def content_types_provided
          [ ["application/hal+json", :to_json],
            ["application/json", :to_json],
            ["text/html", :to_html]]
        end

        def allowed_methods
          ["GET"]
        end

        def resource_exists?
          pact
        end

        def to_json
          response.headers['X-Pact-Consumer-Version'] = pact.consumer_version_number
          PactBroker::Api::Decorators::PactDecorator.new(pact).to_json(user_options: { base_url: base_url })
        end

        def to_html
          PactBroker.configuration.html_pact_renderer.call(pact)
        end

        def pact
          @pact ||= pact_service.find_latest_pact(identifier_from_path)
        end

      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
pact_broker-2.4.2 lib/pact_broker/api/resources/latest_pact.rb
pact_broker-2.4.1 lib/pact_broker/api/resources/latest_pact.rb
pact_broker-2.4.0 lib/pact_broker/api/resources/latest_pact.rb
pact_broker-2.3.0 lib/pact_broker/api/resources/latest_pact.rb
pact_broker-2.2.0 lib/pact_broker/api/resources/latest_pact.rb
pact_broker-2.1.1 lib/pact_broker/api/resources/latest_pact.rb
pact_broker-2.1.0 lib/pact_broker/api/resources/latest_pact.rb
pact_broker-2.0.5 lib/pact_broker/api/resources/latest_pact.rb
pact_broker-2.0.4 lib/pact_broker/api/resources/latest_pact.rb
pact_broker-2.0.3 lib/pact_broker/api/resources/latest_pact.rb
pact_broker-2.0.2 lib/pact_broker/api/resources/latest_pact.rb
pact_broker-2.0.1 lib/pact_broker/api/resources/latest_pact.rb
pact_broker-2.0.0 lib/pact_broker/api/resources/latest_pact.rb
pact_broker-2.0.0.beta.8 lib/pact_broker/api/resources/latest_pact.rb
pact_broker-2.0.0.beta.7 lib/pact_broker/api/resources/latest_pact.rb
pact_broker-2.0.0.beta.6 lib/pact_broker/api/resources/latest_pact.rb