mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
Handle special-case of Array serializer with unserializable elements
This commit is contained in:
committed by
João Moura
parent
cf77786da2
commit
e5d1e40dbd
@@ -1,6 +1,7 @@
|
||||
module ActiveModel
|
||||
class Serializer
|
||||
class ArraySerializer
|
||||
Error = Class.new(StandardError)
|
||||
include Enumerable
|
||||
delegate :each, to: :@objects
|
||||
|
||||
@@ -14,7 +15,9 @@ module ActiveModel
|
||||
ActiveModel::Serializer.serializer_for(object)
|
||||
)
|
||||
|
||||
unless serializer_class.nil?
|
||||
if serializer_class.nil?
|
||||
fail Error, "No serializer found for object: #{object.inspect}"
|
||||
else
|
||||
serializer_class.new(object, options.except(:serializer))
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user