class Researchable::PdfRenderer::Endpoint
@api private
Public Instance Methods
response_to_result(response)
click to toggle source
This function is used so it can be mocked later, and so that it can be specified for each subclass
# File lib/researchable/pdf_renderer/endpoint.rb, line 20 def response_to_result(response) response end
validate_response_for() { || ... }
click to toggle source
# File lib/researchable/pdf_renderer/endpoint.rb, line 11 def validate_response_for response = yield return deal_with_errors if response.parsed_response.is_a?(Hash) && response['errors'].present? return deal_with_unprocessable_entity if response.code == 422 response_to_result response end
Private Instance Methods
deal_with_errors()
click to toggle source
# File lib/researchable/pdf_renderer/endpoint.rb, line 31 def deal_with_errors response['errors'].each do |attribute, attribute_errors| attribute_errors.each do |error| if respond_to?(attribute.to_sym) || attribute.to_sym == :base errors.add attribute.to_sym, error else errors.add :base, error end end end nil end
deal_with_unprocessable_entity()
click to toggle source
# File lib/researchable/pdf_renderer/endpoint.rb, line 26 def deal_with_unprocessable_entity errors.add :base, 'Validations failed!' nil end