mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
Remove Adapter autoloads in favor of require
Adapters must be eager loaded to ensure they are defined
before they are used as namespacing.
cf6a074a1c (diff-41f2b3509d33e1c65bb70ee0ec7a2eea)
This commit is contained in:
@@ -4,13 +4,8 @@ module ActiveModel
|
||||
UnknownAdapterError = Class.new(ArgumentError)
|
||||
ADAPTER_MAP = {}
|
||||
private_constant :ADAPTER_MAP if defined?(private_constant)
|
||||
extend ActiveSupport::Autoload
|
||||
autoload :Attributes
|
||||
autoload :Null
|
||||
autoload :FragmentCache
|
||||
autoload :Json
|
||||
autoload :JsonApi
|
||||
autoload :CachedSerializer
|
||||
require 'active_model/serializer/adapter/fragment_cache'
|
||||
require 'active_model/serializer/adapter/cached_serializer'
|
||||
|
||||
def self.create(resource, options = {})
|
||||
override = options.delete(:adapter)
|
||||
@@ -131,6 +126,12 @@ module ActiveModel
|
||||
json[meta_key] = meta if meta
|
||||
json
|
||||
end
|
||||
|
||||
# Gotta be at the bottom to use the code above it :(
|
||||
require 'active_model/serializer/adapter/null'
|
||||
require 'active_model/serializer/adapter/attributes'
|
||||
require 'active_model/serializer/adapter/json'
|
||||
require 'active_model/serializer/adapter/json_api'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user