Sha256: 106dc967cb50186cc4a9ca279b4f9c865142ef22c9216ab6d9c2da73bf7a9bc1

Contents?: true

Size: 749 Bytes

Versions: 8

Compression:

Stored size: 749 Bytes

Contents

# frozen_string_literal: true

require 'active_model/serializer/error_serializer'

module ActiveModel
  class Serializer
    class ErrorsSerializer
      include Enumerable
      delegate :each, to: :@serializers
      attr_reader :object, :root

      def initialize(resources, options = {})
        @root = options[:root]
        @object = resources
        @serializers = resources.map do |resource|
          serializer_class = options.fetch(:serializer) { ActiveModel::Serializer::ErrorSerializer }
          serializer_class.new(resource, options.except(:serializer))
        end
      end

      def success?
        false
      end

      def json_key
        nil
      end

      protected

      attr_reader :serializers
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
active_model_serializers-0.10.15 lib/active_model/serializer/errors_serializer.rb
active_model_serializers-0.10.14 lib/active_model/serializer/errors_serializer.rb
active_model_serializers-0.10.13 lib/active_model/serializer/errors_serializer.rb
active_model_serializers-0.10.12 lib/active_model/serializer/errors_serializer.rb
active_model_serializers-0.10.11 lib/active_model/serializer/errors_serializer.rb
active_model_serializers-0.10.10 lib/active_model/serializer/errors_serializer.rb
active_model_serializers_custom-0.10.90 lib/active_model/serializer/errors_serializer.rb
active_model_serializers-0.10.9 lib/active_model/serializer/errors_serializer.rb