Skip to content

Commit

Permalink
Handle render.ams with nil serializer or adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
bf4 committed Mar 29, 2016
1 parent 84197e4 commit ec5dc49
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/active_model/serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module ActiveModel
class Serializer
extend ActiveSupport::Autoload
autoload :Adapter
autoload :Null
include Configuration
include Associations
include Attributes
Expand Down
17 changes: 17 additions & 0 deletions lib/active_model/serializer/null.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module ActiveModel
class Serializer
class Null < Serializer
def attributes(*)
{}
end

def associations(*)
{}
end

def serializable_hash(*)
{}
end
end
end
end
5 changes: 4 additions & 1 deletion lib/active_model_serializers/logging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ def notify_render(*)
end

def notify_render_payload
{ serializer: serializer, adapter: adapter }
{
serializer: serializer || ActiveModel::Serializer::Null,
adapter: adapter || ActiveModelSerializers::Adapter::Null
}
end

private
Expand Down

0 comments on commit ec5dc49

Please sign in to comment.