Sha256: ceb8716a12c8753d9f425f5be1f8e70f297b6dff81054a1c2d370b9f50e3c460

Contents?: true

Size: 1.26 KB

Versions: 14

Compression:

Stored size: 1.26 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(decorator_options)
        end

        def delete_resource
          version_service.delete version
          true
        end

        def policy_name
          :'versions::version'
        end

        private

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

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
pact_broker-2.74.1 lib/pact_broker/api/resources/version.rb
pact_broker-2.74.0 lib/pact_broker/api/resources/version.rb
pact_broker-2.73.0 lib/pact_broker/api/resources/version.rb
pact_broker-2.72.0 lib/pact_broker/api/resources/version.rb
pact_broker-2.71.0 lib/pact_broker/api/resources/version.rb
pact_broker-2.70.0 lib/pact_broker/api/resources/version.rb
pact_broker-2.69.0 lib/pact_broker/api/resources/version.rb
pact_broker-2.68.1 lib/pact_broker/api/resources/version.rb
pact_broker-2.68.0 lib/pact_broker/api/resources/version.rb
pact_broker-2.67.0 lib/pact_broker/api/resources/version.rb
pact_broker-2.66.0 lib/pact_broker/api/resources/version.rb
pact_broker-2.65.0 lib/pact_broker/api/resources/version.rb
pact_broker-2.64.0 lib/pact_broker/api/resources/version.rb
pact_broker-2.63.0 lib/pact_broker/api/resources/version.rb