class PactBroker::Api::Resources::Pacticipant
Public Instance Methods
Source
# File lib/pact_broker/api/resources/pacticipant.rb, line 20 def allowed_methods ["GET", "PUT", "PATCH", "DELETE", "OPTIONS"] end
Source
# File lib/pact_broker/api/resources/pacticipant.rb, line 13 def content_types_accepted [ ["application/json", :from_json], ["application/merge-patch+json", :from_merge_patch_json] ] end
Source
# File lib/pact_broker/api/resources/pacticipant.rb, line 9 def content_types_provided [["application/hal+json", :to_json]] end
Source
# File lib/pact_broker/api/resources/pacticipant.rb, line 102 def create_new_pacticipant pacticipant_service.create parsed_pacticipant(OpenStruct.new).to_h.merge(:name => pacticipant_name) end
Source
# File lib/pact_broker/api/resources/pacticipant.rb, line 68 def delete_resource pacticipant_service.delete(pacticipant_name) true end
Source
# File lib/pact_broker/api/resources/pacticipant.rb, line 78 def deployed_versions @deployed_versions ||= deployed_version_service.find_all_deployed_versions_for_pacticipant(pacticipant) end
Source
# File lib/pact_broker/api/resources/pacticipant.rb, line 41 def from_json if pacticipant @pacticipant = update_existing_pacticipant else if request.patch? # for backwards compatibility, wish I hadn't done this @pacticipant = create_new_pacticipant response.headers["Location"] = pacticipant_url(base_url, pacticipant) else return 404 end end response.body = to_json end
PUT or PATCH with content-type application/json
Source
# File lib/pact_broker/api/resources/pacticipant.rb, line 56 def from_merge_patch_json if request.patch? from_json else 415 end end
PUT or PATCH with content-type application/merge-patch+json
Source
# File lib/pact_broker/api/resources/pacticipant.rb, line 32 def known_methods super + ["PATCH"] end
Calls superclass method
PactBroker::Api::Resources::BaseResource#known_methods
Source
# File lib/pact_broker/api/resources/pacticipant.rb, line 36 def malformed_request? super || ((request.patch? || request.really_put?) && any_request_body? && validation_errors_for_schema?) end
Calls superclass method
PactBroker::Api::Resources::BaseResource#malformed_request?
Source
# File lib/pact_broker/api/resources/pacticipant.rb, line 82 def parsed_pacticipant(pacticipant) decorator_class(:pacticipant_decorator).new(pacticipant).from_json(request_body) end
Source
# File lib/pact_broker/api/resources/pacticipant.rb, line 28 def patch_can_create? true end
Source
# File lib/pact_broker/api/resources/pacticipant.rb, line 86 def policy_name :'pacticipants::pacticipant' end
Source
# File lib/pact_broker/api/resources/pacticipant.rb, line 24 def put_can_create? false end
Source
# File lib/pact_broker/api/resources/pacticipant.rb, line 64 def resource_exists? !!pacticipant end
Source
# File lib/pact_broker/api/resources/pacticipant.rb, line 90 def schema PactBroker::Api::Contracts::PacticipantSchema end
Source
# File lib/pact_broker/api/resources/pacticipant.rb, line 73 def to_json decorator_class(:pacticipant_decorator).new(pacticipant) .to_json(**decorator_options(deployed_versions: deployed_versions)) end
Source
# File lib/pact_broker/api/resources/pacticipant.rb, line 94 def update_existing_pacticipant if request.really_put? @pacticipant = pacticipant_service.replace(pacticipant_name, parsed_pacticipant(OpenStruct.new)) else @pacticipant = pacticipant_service.update(pacticipant_name, parsed_pacticipant(pacticipant)) end end