Class: PactBroker::Api::Resources::Tag

Inherits:
BaseResource
  • Object
show all
Defined in:
lib/pact_broker/api/resources/tag.rb

Instance Method Summary collapse

Instance Method Details

#allowed_methodsObject



16
17
18
# File 'lib/pact_broker/api/resources/tag.rb', line 16

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

#content_types_acceptedObject



12
13
14
# File 'lib/pact_broker/api/resources/tag.rb', line 12

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

#content_types_providedObject



8
9
10
# File 'lib/pact_broker/api/resources/tag.rb', line 8

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

#delete_resourceObject



42
43
44
45
# File 'lib/pact_broker/api/resources/tag.rb', line 42

def delete_resource
  tag_service.delete identifier_from_path
  true
end

#from_jsonObject



20
21
22
23
24
25
26
27
28
# File 'lib/pact_broker/api/resources/tag.rb', line 20

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

#policy_nameObject



47
48
49
# File 'lib/pact_broker/api/resources/tag.rb', line 47

def policy_name
  :'tags::tag'
end

#resource_exists?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/pact_broker/api/resources/tag.rb', line 30

def resource_exists?
  !!tag
end

#tagObject



38
39
40
# File 'lib/pact_broker/api/resources/tag.rb', line 38

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

#to_jsonObject



34
35
36
# File 'lib/pact_broker/api/resources/tag.rb', line 34

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