Class: PactBroker::Api::Resources::Pacticipant
- Inherits:
-
BaseResource
- Object
- BaseResource
- PactBroker::Api::Resources::Pacticipant
- Defined in:
- lib/pact_broker/api/resources/pacticipant.rb
Instance Method Summary collapse
- #allowed_methods ⇒ Object
- #content_types_accepted ⇒ Object
- #content_types_provided ⇒ Object
- #delete_resource ⇒ Object
- #from_json ⇒ Object
- #known_methods ⇒ Object
- #policy_resource ⇒ Object
- #resource_exists? ⇒ Boolean
- #resource_object ⇒ Object
- #to_json ⇒ Object
Instance Method Details
#allowed_methods ⇒ Object
24 25 26 |
# File 'lib/pact_broker/api/resources/pacticipant.rb', line 24 def allowed_methods ["GET", "PATCH", "DELETE", "OPTIONS"] end |
#content_types_accepted ⇒ Object
20 21 22 |
# File 'lib/pact_broker/api/resources/pacticipant.rb', line 20 def content_types_accepted [["application/json", :from_json]] end |
#content_types_provided ⇒ Object
16 17 18 |
# File 'lib/pact_broker/api/resources/pacticipant.rb', line 16 def content_types_provided [["application/hal+json", :to_json]] end |
#delete_resource ⇒ Object
54 55 56 57 |
# File 'lib/pact_broker/api/resources/pacticipant.rb', line 54 def delete_resource pacticipant_service.delete(pacticipant_name) true end |
#from_json ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/pact_broker/api/resources/pacticipant.rb', line 32 def from_json if pacticipant @pacticipant = pacticipant_service.update params(symbolize_names: false).merge('name' => pacticipant_name) else @pacticipant = pacticipant_service.create params.merge(:name => pacticipant_name) response.headers["Location"] = pacticipant_url(base_url, pacticipant) end response.body = to_json end |
#known_methods ⇒ Object
28 29 30 |
# File 'lib/pact_broker/api/resources/pacticipant.rb', line 28 def known_methods super + ['PATCH'] end |
#policy_resource ⇒ Object
50 51 52 |
# File 'lib/pact_broker/api/resources/pacticipant.rb', line 50 def policy_resource pacticipant end |
#resource_exists? ⇒ Boolean
42 43 44 |
# File 'lib/pact_broker/api/resources/pacticipant.rb', line 42 def resource_exists? !!resource_object end |
#resource_object ⇒ Object
46 47 48 |
# File 'lib/pact_broker/api/resources/pacticipant.rb', line 46 def resource_object pacticipant end |
#to_json ⇒ Object
59 60 61 |
# File 'lib/pact_broker/api/resources/pacticipant.rb', line 59 def to_json PactBroker::Api::Decorators::PacticipantDecorator.new(pacticipant).to_json() end |