From 4359026c0edc351edb5b38c73573bea0dc0ca7c0 Mon Sep 17 00:00:00 2001 From: Benjamin Fleischer Date: Fri, 17 Jul 2015 14:08:50 -0500 Subject: [PATCH] Handle inflecting api to s/API/Api without side-effects --- lib/active_model/serializer/adapter.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/active_model/serializer/adapter.rb b/lib/active_model/serializer/adapter.rb index 852fa53e2..7c0614342 100644 --- a/lib/active_model/serializer/adapter.rb +++ b/lib/active_model/serializer/adapter.rb @@ -33,7 +33,8 @@ def self.create(resource, options = {}) end def self.adapter_class(adapter) - "ActiveModel::Serializer::Adapter::#{adapter.to_s.classify}".safe_constantize + adapter_name = adapter.to_s.classify.sub("API", "Api") + "ActiveModel::Serializer::Adapter::#{adapter_name}".safe_constantize end def fragment_cache(*args) @@ -42,7 +43,7 @@ def fragment_cache(*args) private - def cache_check(serializer) + def cache_check(serializer) @cached_serializer = serializer @klass = @cached_serializer.class if is_cached?