Sha256: 23fb40106d6365650cf1257f113b261e925f9f830e4b2a922c9d33431b977988

Contents?: true

Size: 480 Bytes

Versions: 8

Compression:

Stored size: 480 Bytes

Contents

module ApiPack
  module Errors
    class ValidationErrorSerializer
      def initialize(record, field, message)
        @record = record
        @field = field
        @message = message
      end

      def serialize
        {
          resource: underscored_resource_name,
          field: @field,
          detail: @message
        }
      end

      private

      def underscored_resource_name
        @record.class.to_s.gsub('::', '').underscore
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
api_pack-1.3.1 lib/api_pack/errors/validation_error_serializer.rb
api_pack-1.2.1 lib/api_pack/errors/validation_error_serializer.rb
api_pack-1.1.4 lib/api_pack/errors/validation_error_serializer.rb
api_pack-1.1.3 lib/api_pack/errors/validation_error_serializer.rb
api_pack-1.1.2 lib/api_pack/errors/validation_error_serializer.rb
api_pack-1.1.1 lib/api_pack/errors/validation_error_serializer.rb
api_pack-1.0.1 lib/api_pack/errors/validation_error_serializer.rb
api_pack-1.0.0 lib/api_pack/errors/validation_error_serializer.rb