Sha256: 5c876c1fb450f19348903f22139658e7d0cdefe2b2d46559f989566df1860a1e

Contents?: true

Size: 774 Bytes

Versions: 14

Compression:

Stored size: 774 Bytes

Contents

# frozen_string_literal: true

require 'json'
require 'pi_resources/serializer/base'

module PiResources
  module Serializer
    class ValidationResponseSerializer
      include Base

      attr_reader :message

      def initialize(resource, message = nil)
        @resource             = resource
        @message              = message
      end

      protected

      def validation_response
        @resource.attributes.symbolize_keys.deep_transform_keys do |k|
          run_key_transform!(k)
        end
      end

      def serializable_hash!
        result = {}

        result[run_key_transform!(:validation_response)] = validation_response
        result[run_key_transform!(:message)]             = message if message

        result
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
pi-resources-rails-0.6.3 lib/pi_resources/serializer/validation_response_serializer.rb
pi-resources-rails-0.6.2 lib/pi_resources/serializer/validation_response_serializer.rb
pi-resources-rails-0.6.1 lib/pi_resources/serializer/validation_response_serializer.rb
pi-resources-rails-0.6.0 lib/pi_resources/serializer/validation_response_serializer.rb
pi-resources-rails-0.5.0 lib/pi_resources/serializer/validation_response_serializer.rb
pi-resources-rails-0.4.4 lib/pi_resources/serializer/validation_response_serializer.rb
pi-resources-rails-0.4.3 lib/pi_resources/serializer/validation_response_serializer.rb
pi-resources-rails-0.4.2 lib/pi_resources/serializer/validation_response_serializer.rb
pi-resources-rails-0.4.1 lib/pi_resources/serializer/validation_response_serializer.rb
pi-resources-rails-0.4.0 lib/pi_resources/serializer/validation_response_serializer.rb
pi-resources-rails-0.3.0 lib/pi_resources/serializer/validation_response_serializer.rb
pi-resources-rails-0.2.0 lib/pi_resources/serializer/validation_response_serializer.rb
pi-resources-rails-0.1.1 lib/pi_resources/serializer/validation_response_serializer.rb
pi-resources-rails-0.1.0 lib/pi_resources/serializer/validation_response_serializer.rb