Sha256: 5a5b18f0d9ea9c0f449de118c9a398e27050a6bc1524d0257e8090bf298904b3

Contents?: true

Size: 1.13 KB

Versions: 4

Compression:

Stored size: 1.13 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"]
        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_pacticpant_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

4 entries across 4 versions & 1 rubygems

Version Path
pact_broker-2.16.1 lib/pact_broker/api/resources/version.rb
pact_broker-2.16.0 lib/pact_broker/api/resources/version.rb
pact_broker-2.15.0 lib/pact_broker/api/resources/version.rb
pact_broker-2.14.0 lib/pact_broker/api/resources/version.rb