From a1ff18092d4fe3a6e162e690c5088ee300cf05aa Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Wed, 21 Dec 2022 01:20:55 -0800 Subject: [PATCH] Create error_blueprint.rb --- app/blueprints/api/v1/error_blueprint.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 app/blueprints/api/v1/error_blueprint.rb diff --git a/app/blueprints/api/v1/error_blueprint.rb b/app/blueprints/api/v1/error_blueprint.rb new file mode 100644 index 0000000..92a9580 --- /dev/null +++ b/app/blueprints/api/v1/error_blueprint.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module Api + module V1 + class ErrorBlueprint < Blueprinter::Base + field :error, if: ->(_field_name, _error, options) { options.key?(:error) } do |_, options| + options[:error] + end + + field :errors, if: ->(_field_name, _error, options) { options.key?(:errors) } do |_, options| + options[:errors] + end + end + end +end