Merge pull request #1353 from bf4/disable_serializer_lookup

Allow users to globally opt out of automatic serializer lookup
This commit is contained in:
Benjamin Fleischer
2015-12-20 20:04:16 -06:00
7 changed files with 59 additions and 9 deletions

View File

@@ -172,6 +172,7 @@ module ActiveModel
# 2. try again with superclass, if present
# 3. nil
def self.get_serializer_for(klass)
return nil unless config.serializer_lookup_enabled
serializers_cache.fetch_or_store(klass) do
# NOTE(beauby): When we drop 1.9.3 support we can lazify the map for perfs.
serializer_class = serializer_lookup_chain_for(klass).map(&:safe_constantize).find { |x| x && x < ActiveModel::Serializer }