Sha256: c7406d360b160f1d93aa36c16b4376aa46837affe8ffd126193be1eaa3ab8013

Contents?: true

Size: 731 Bytes

Versions: 3

Compression:

Stored size: 731 Bytes

Contents

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

module PactBroker::Api

  module Resources

    class LatestPact < BaseResource

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

      def allowed_methods
        ["GET"]
      end

      def resource_exists?
        @pact = pact_service.find_latest_pact(identifier_from_path)
        @pact != nil
      end

      def to_json
        response.headers['X-Pact-Consumer-Version'] = @pact.consumer_version_number
        @pact.json_content
      end

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

    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pact_broker-1.0.0 lib/pact_broker/api/resources/latest_pact.rb
pact_broker-1.0.0.alpha3 lib/pact_broker/api/resources/latest_pact.rb
pact_broker-1.0.0.alpha2 lib/pact_broker/api/resources/latest_pact.rb