Sha256: a67ee49177db8e97e1dad5d70591ad078a601171bfdf9527b1f0b725edb6f470

Contents?: true

Size: 951 Bytes

Versions: 1

Compression:

Stored size: 951 Bytes

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"]
        end

        def from_json
          unless @tag
            @tag = tag_service.create identifier_from_path
            response.headers["Location"] = tag_url(base_url, @tag)
          end
          response.body = generate_json @tag
        end

        def resource_exists?
          @tag = tag_service.find identifier_from_path
        end

        def to_json
          generate_json(@tag)
        end

        def generate_json tag
          PactBroker::Api::Decorators::TagDecorator.new(tag).to_json(base_url: base_url)
        end

      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pact_broker-1.2.0 lib/pact_broker/api/resources/tag.rb