Handle render.ams with nil serializer or adapter

This commit is contained in:
Benjamin Fleischer 2016-03-28 20:10:55 -05:00
parent 84197e4dad
commit ec5dc497b0
3 changed files with 22 additions and 1 deletions

View File

@ -20,6 +20,7 @@ module ActiveModel
class Serializer class Serializer
extend ActiveSupport::Autoload extend ActiveSupport::Autoload
autoload :Adapter autoload :Adapter
autoload :Null
include Configuration include Configuration
include Associations include Associations
include Attributes include Attributes

View 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

View File

@ -81,7 +81,10 @@ module ActiveModelSerializers
end end
def notify_render_payload def notify_render_payload
{ serializer: serializer, adapter: adapter } {
serializer: serializer || ActiveModel::Serializer::Null,
adapter: adapter || ActiveModelSerializers::Adapter::Null
}
end end
private private