Sha256: 8bc2bcf07824068eef455ed451d44dafbdb0e3c4840d24bddc3d03f2ef0556ce

Contents?: true

Size: 718 Bytes

Versions: 10

Compression:

Stored size: 718 Bytes

Contents

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

10 entries across 10 versions & 2 rubygems

Version Path
active_model_serializers-0.10.8 lib/active_model/serializer/errors_serializer.rb
active_model_serializers-0.10.7 lib/active_model/serializer/errors_serializer.rb
active_model_serializers-0.10.6 lib/active_model/serializer/errors_serializer.rb
active_model_serializers-0.10.5 lib/active_model/serializer/errors_serializer.rb
active_model_serializers-0.10.4 lib/active_model/serializer/errors_serializer.rb
agi_active_model_serializers-0.10.9 lib/active_model/serializer/errors_serializer.rb
agi_active_model_serializers-0.10.8 lib/active_model/serializer/errors_serializer.rb
agi_active_model_serializers-0.10.7 lib/active_model/serializer/errors_serializer.rb
active_model_serializers-0.10.3 lib/active_model/serializer/errors_serializer.rb
active_model_serializers-0.10.2 lib/active_model/serializer/errors_serializer.rb