Sha256: 059444036809d6a7b413f14dda1bf9ccaeed691fb8007aa381b7f043fc6d0e22

Contents?: true

Size: 1.3 KB

Versions: 8

Compression:

Stored size: 1.3 KB

Contents

require "pact_broker/api/resources/base_resource"

module PactBroker
  module Api
    module Resources
      class Tag < BaseResource

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

        def content_types_accepted
          [["application/json", :from_json]]
        end

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

        def put_can_create?
          true
        end

        def from_json
          unless tag
            @tag = tag_service.create(identifier_from_path)
            # Make it return a 201 by setting the Location header
            response.headers["Location"] = tag_url(base_url, tag)
          end
          deployed_version_service.maybe_create_deployed_version_for_tag(tag.version, identifier_from_path[:tag_name])
          response.body = to_json
        end

        def resource_exists?
          !!tag
        end

        def to_json
          decorator_class(:tag_decorator).new(tag).to_json(**decorator_options)
        end

        def tag
          @tag ||= tag_service.find(identifier_from_path)
        end

        def delete_resource
          tag_service.delete(identifier_from_path)
          true
        end

        def policy_name
          :'tags::tag'
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
pact_broker-2.112.0 lib/pact_broker/api/resources/tag.rb
pact_broker-2.111.0 lib/pact_broker/api/resources/tag.rb
pact_broker-2.109.1 lib/pact_broker/api/resources/tag.rb
pact_broker-2.109.0 lib/pact_broker/api/resources/tag.rb
pact_broker-2.108.0 lib/pact_broker/api/resources/tag.rb
pact_broker-2.107.1 lib/pact_broker/api/resources/tag.rb
pact_broker-2.107.0 lib/pact_broker/api/resources/tag.rb
pact_broker-2.107.0.beta.1 lib/pact_broker/api/resources/tag.rb