mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-24 23:06:50 +00:00
Simplify adapter deprecation and delegation
The Adapter module was refactored a bit to use Active Support delegation and remove duplicated code. The CHANGELOG was also added.
This commit is contained in:
parent
b50195fde7
commit
8dfbc4818d
@ -29,6 +29,7 @@ Fixes:
|
|||||||
- [#1488](https://github.com/rails-api/active_model_serializers/pull/1488) Require ActiveSupport's string inflections (@nate00)
|
- [#1488](https://github.com/rails-api/active_model_serializers/pull/1488) Require ActiveSupport's string inflections (@nate00)
|
||||||
|
|
||||||
Misc:
|
Misc:
|
||||||
|
- [#1559](https://github.com/rails-api/active_model_serializers/pull/1559) Add a deprecation DSL. (@bf4 @groyoh)
|
||||||
- [#1543](https://github.com/rails-api/active_model_serializers/pull/1543) Add the changes missing from #1535. (@groyoh)
|
- [#1543](https://github.com/rails-api/active_model_serializers/pull/1543) Add the changes missing from #1535. (@groyoh)
|
||||||
- [#1535](https://github.com/rails-api/active_model_serializers/pull/1535) Move the adapter and adapter folder to
|
- [#1535](https://github.com/rails-api/active_model_serializers/pull/1535) Move the adapter and adapter folder to
|
||||||
active_model_serializers folder and changes the module namespace. (@domitian @bf4)
|
active_model_serializers folder and changes the module namespace. (@domitian @bf4)
|
||||||
|
|||||||
@ -5,35 +5,18 @@ module ActiveModel
|
|||||||
class << self
|
class << self
|
||||||
extend ActiveModelSerializers::Deprecate
|
extend ActiveModelSerializers::Deprecate
|
||||||
|
|
||||||
def create(resource, options = {})
|
def self.delegate_and_deprecate(method)
|
||||||
ActiveModelSerializers::Adapter.create(resource, options)
|
delegate method, to: ActiveModelSerializers::Adapter
|
||||||
|
deprecate method, 'ActiveModelSerializers::Adapter.'
|
||||||
end
|
end
|
||||||
deprecate :create, 'ActiveModelSerializers::Adapter.'
|
private_class_method :delegate_and_deprecate
|
||||||
|
|
||||||
def adapter_class(adapter)
|
delegate_and_deprecate :create
|
||||||
ActiveModelSerializers::Adapter.adapter_class(adapter)
|
delegate_and_deprecate :adapter_class
|
||||||
end
|
delegate_and_deprecate :adapter_map
|
||||||
deprecate :adapter_class, 'ActiveModelSerializers::Adapter.'
|
delegate_and_deprecate :adapters
|
||||||
|
delegate_and_deprecate :register
|
||||||
def adapter_map
|
delegate_and_deprecate :lookup
|
||||||
ActiveModelSerializers::Adapter.adapter_map
|
|
||||||
end
|
|
||||||
deprecate :adapter_map, 'ActiveModelSerializers::Adapter.'
|
|
||||||
|
|
||||||
def adapters
|
|
||||||
ActiveModelSerializers::Adapter.adapters
|
|
||||||
end
|
|
||||||
deprecate :adapters, 'ActiveModelSerializers::Adapter.'
|
|
||||||
|
|
||||||
def register(name, klass = name)
|
|
||||||
ActiveModelSerializers::Adapter.register(name, klass)
|
|
||||||
end
|
|
||||||
deprecate :register, 'ActiveModelSerializers::Adapter.'
|
|
||||||
|
|
||||||
def lookup(adapter)
|
|
||||||
ActiveModelSerializers::Adapter.lookup(adapter)
|
|
||||||
end
|
|
||||||
deprecate :lookup, 'ActiveModelSerializers::Adapter.'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
require 'active_model/serializer/adapter/base'
|
require 'active_model/serializer/adapter/base'
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user