mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 15:23:06 +00:00
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:
@@ -94,9 +94,9 @@ module ActiveModel
|
||||
end
|
||||
end
|
||||
|
||||
# @see ActiveModel::Serializer::Adapter.get
|
||||
# @see ActiveModel::Serializer::Adapter.lookup
|
||||
def self.adapter
|
||||
ActiveModel::Serializer::Adapter.get(config.adapter)
|
||||
ActiveModel::Serializer::Adapter.lookup(config.adapter)
|
||||
end
|
||||
|
||||
def self.root_name
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user