Sha256: b0e300678163cad8649db39e5a509fa0a6839a17bb0043be3a791af690ed0840

Contents?: true

Size: 889 Bytes

Versions: 5

Compression:

Stored size: 889 Bytes

Contents

require 'pact_broker/api/resources/base_resource'

module PactBroker::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(resource_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: resource_url)
      end

    end
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pact_broker-1.0.0 lib/pact_broker/api/resources/tag.rb
pact_broker-1.0.0.alpha3 lib/pact_broker/api/resources/tag.rb
pact_broker-1.0.0.alpha2 lib/pact_broker/api/resources/tag.rb
pact_broker-1.0.0.alpha1 lib/pact_broker/api/resources/tag.rb
pact_broker-0.0.10 lib/pact_broker/api/resources/tag.rb