mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 15:23:06 +00:00
Handle render.ams with nil serializer or adapter
This commit is contained in:
@@ -20,6 +20,7 @@ module ActiveModel
|
||||
class Serializer
|
||||
extend ActiveSupport::Autoload
|
||||
autoload :Adapter
|
||||
autoload :Null
|
||||
include Configuration
|
||||
include Associations
|
||||
include Attributes
|
||||
|
||||
17
lib/active_model/serializer/null.rb
Normal file
17
lib/active_model/serializer/null.rb
Normal file
@@ -0,0 +1,17 @@
|
||||
module ActiveModel
|
||||
class Serializer
|
||||
class Null < Serializer
|
||||
def attributes(*)
|
||||
{}
|
||||
end
|
||||
|
||||
def associations(*)
|
||||
{}
|
||||
end
|
||||
|
||||
def serializable_hash(*)
|
||||
{}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -81,7 +81,10 @@ module ActiveModelSerializers
|
||||
end
|
||||
|
||||
def notify_render_payload
|
||||
{ serializer: serializer, adapter: adapter }
|
||||
{
|
||||
serializer: serializer || ActiveModel::Serializer::Null,
|
||||
adapter: adapter || ActiveModelSerializers::Adapter::Null
|
||||
}
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
Reference in New Issue
Block a user