mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
Allow to define custom serializer for given class by defining #serializer_class method in serialized object's class. Resolves #515.
This commit is contained in:
@@ -115,7 +115,9 @@ module ActiveModel
|
||||
end
|
||||
|
||||
def self.serializer_for(resource, options = {})
|
||||
if resource.respond_to?(:to_ary)
|
||||
if resource.respond_to?(:serializer_class)
|
||||
resource.serializer_class
|
||||
elsif resource.respond_to?(:to_ary)
|
||||
config.array_serializer
|
||||
else
|
||||
options
|
||||
|
||||
Reference in New Issue
Block a user