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:
Benjamin Fleischer
2015-09-18 10:19:40 -05:00
parent a30913229f
commit ad2ca3b45c
13 changed files with 75 additions and 58 deletions

View File

@@ -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