Rename Adapter.get to Adapter.lookup

Per https://github.com/rails-api/active_model_serializers/pull/1017#discussion_r39003855
comment by sandstrom in discussion of the inherited hook

> I'm thinking that it would be better to register adapters manually, without using the hook, i.e.
> have people call ActiveModel::Serializer::Adapter.register directly (perhaps in an initializer).

> Possibly, some inspiration can be taken from how ActiveJob adapters are wired[1].

> [1] a11571cec3/activejob/lib/active_job/queue_adapter.rb (L52-L56)
This commit is contained in:
Benjamin Fleischer
2015-09-08 22:57:53 -05:00
parent af99c0d9e6
commit 363345b8dd
4 changed files with 23 additions and 23 deletions

View File

@@ -17,9 +17,9 @@ module ActiveModel
klass.new(resource, options)
end
# @see ActiveModel::Serializer::Adapter.get
# @see ActiveModel::Serializer::Adapter.lookup
def self.adapter_class(adapter)
ActiveModel::Serializer::Adapter.get(adapter)
ActiveModel::Serializer::Adapter.lookup(adapter)
end
# Only the Adapter class has these methods.
@@ -49,7 +49,7 @@ module ActiveModel
# @param adapter [String, Symbol, Class] name to fetch adapter by
# @return [ActiveModel::Serializer::Adapter] subclass of Adapter
# @raise [UnknownAdapterError]
def get(adapter)
def lookup(adapter)
# 1. return if is a class
return adapter if adapter.is_a?(Class)
adapter_name = adapter.to_s.underscore