Sha256: 9693cc5a321156cd7e6af65e7fbcc2dc39380e8de0cc224937b4b3990670a541

Contents?: true

Size: 1.15 KB

Versions: 46

Compression:

Stored size: 1.15 KB

Contents

require 'pact_broker/services'
require 'pact_broker/api/decorators/version_decorator'
require 'pact_broker/api/resources/base_resource'

module PactBroker
  module Api
    module Resources

      class Version < BaseResource

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

        def allowed_methods
          ["GET", "DELETE", "OPTIONS"]
        end

        def resource_exists?
          version
        end

        def to_json
          Decorators::VersionDecorator.new(version).to_json(user_options: {base_url: base_url})
        end

        def delete_resource
          version_service.delete version
          true
        end

        private

        def version
          if path_info[:tag]
            @version ||= version_service.find_by_pacticipant_name_and_latest_tag(path_info[:pacticipant_name], path_info[:tag])
          elsif path_info[:pacticipant_version_number]
            @version ||= version_service.find_by_pacticipant_name_and_number path_info
          else
            @version ||= version_service.find_latest_by_pacticpant_name path_info
          end
        end
      end
    end
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
pact_broker-2.58.0 lib/pact_broker/api/resources/version.rb
pact_broker-2.57.0 lib/pact_broker/api/resources/version.rb
pact_broker-2.56.1 lib/pact_broker/api/resources/version.rb
pact_broker-2.56.0 lib/pact_broker/api/resources/version.rb
pact_broker-2.55.0 lib/pact_broker/api/resources/version.rb
pact_broker-2.54.0 lib/pact_broker/api/resources/version.rb
pact_broker-2.53.0 lib/pact_broker/api/resources/version.rb
pact_broker-2.52.2 lib/pact_broker/api/resources/version.rb
pact_broker-2.52.1 lib/pact_broker/api/resources/version.rb
pact_broker-2.52.0 lib/pact_broker/api/resources/version.rb
pact_broker-2.51.0 lib/pact_broker/api/resources/version.rb
pact_broker-2.50.1 lib/pact_broker/api/resources/version.rb
pact_broker-2.50.0 lib/pact_broker/api/resources/version.rb
pact_broker-2.49.0 lib/pact_broker/api/resources/version.rb
pact_broker-2.48.0 lib/pact_broker/api/resources/version.rb
pact_broker-2.47.1 lib/pact_broker/api/resources/version.rb
pact_broker-2.47.0 lib/pact_broker/api/resources/version.rb
pact_broker-2.46.0 lib/pact_broker/api/resources/version.rb
pact_broker-2.45.0 lib/pact_broker/api/resources/version.rb
pact_broker-2.44.0 lib/pact_broker/api/resources/version.rb