Class: PactBroker::Api::Resources::Label
- Inherits:
-
BaseResource
- Object
- BaseResource
- PactBroker::Api::Resources::Label
- Defined in:
- lib/pact_broker/api/resources/label.rb
Instance Method Summary collapse
- #allowed_methods ⇒ Object
- #content_types_accepted ⇒ Object
- #content_types_provided ⇒ Object
- #delete_resource ⇒ Object
- #from_json ⇒ Object
- #label ⇒ Object
- #policy_name ⇒ Object
- #resource_exists? ⇒ Boolean
- #to_json ⇒ Object
Instance Method Details
#allowed_methods ⇒ Object
16 17 18 |
# File 'lib/pact_broker/api/resources/label.rb', line 16 def allowed_methods ["GET", "PUT", "DELETE", "OPTIONS"] end |
#content_types_accepted ⇒ Object
12 13 14 |
# File 'lib/pact_broker/api/resources/label.rb', line 12 def content_types_accepted [["application/json", :from_json]] end |
#content_types_provided ⇒ Object
8 9 10 |
# File 'lib/pact_broker/api/resources/label.rb', line 8 def content_types_provided [["application/hal+json", :to_json]] end |
#delete_resource ⇒ Object
45 46 47 48 |
# File 'lib/pact_broker/api/resources/label.rb', line 45 def delete_resource label_service.delete(identifier_from_path) true end |
#from_json ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/pact_broker/api/resources/label.rb', line 20 def from_json unless label @label = label_service.create(identifier_from_path) # Make it return a 201 by setting the Location header response.headers["Location"] = label_url(label, base_url) end response.body = to_json end |
#label ⇒ Object
41 42 43 |
# File 'lib/pact_broker/api/resources/label.rb', line 41 def label @label ||= label_service.find(identifier_from_path) end |
#policy_name ⇒ Object
33 34 35 |
# File 'lib/pact_broker/api/resources/label.rb', line 33 def policy_name :'labels::label' end |
#resource_exists? ⇒ Boolean
29 30 31 |
# File 'lib/pact_broker/api/resources/label.rb', line 29 def resource_exists? !!label end |
#to_json ⇒ Object
37 38 39 |
# File 'lib/pact_broker/api/resources/label.rb', line 37 def to_json decorator_class(:label_decorator).new(label).to_json() end |