class Roqua::RomApi::Endpoint

@api private

Private Instance Methods

response_to_result(response) click to toggle source
# File lib/roqua/rom_api/endpoint.rb, line 32
def response_to_result(response)
  response
end
validate_response_for() { || ... } click to toggle source
# File lib/roqua/rom_api/endpoint.rb, line 11
def validate_response_for
  response = yield
  if response.parsed_response.is_a?(Hash) && response['errors'].present?
    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.to_sym
        else
          errors.add :base, [attribute, error].join('_').to_sym
        end
      end
    end
    nil
  elsif response.code == 422
    errors.add :base, 'Validations failed!'
    nil
  else
    response_to_result response
  end
end