Sha256: c32525d77ef9f35978f2bd5355bb591f18be790cf167649e1645ad1a3ecae289

Contents?: true

Size: 1.13 KB

Versions: 10

Compression:

Stored size: 1.13 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 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
          response.body = to_json
        end

        def resource_exists?
          !!tag
        end

        def to_json
          PactBroker::Api::Decorators::TagDecorator.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

10 entries across 10 versions & 1 rubygems

Version Path
pact_broker-2.74.1 lib/pact_broker/api/resources/tag.rb
pact_broker-2.74.0 lib/pact_broker/api/resources/tag.rb
pact_broker-2.73.0 lib/pact_broker/api/resources/tag.rb
pact_broker-2.72.0 lib/pact_broker/api/resources/tag.rb
pact_broker-2.71.0 lib/pact_broker/api/resources/tag.rb
pact_broker-2.70.0 lib/pact_broker/api/resources/tag.rb
pact_broker-2.69.0 lib/pact_broker/api/resources/tag.rb
pact_broker-2.68.1 lib/pact_broker/api/resources/tag.rb
pact_broker-2.68.0 lib/pact_broker/api/resources/tag.rb
pact_broker-2.67.0 lib/pact_broker/api/resources/tag.rb