Skip to content

Commit 506636a

Browse files
committed
Merge branch 'f-mer-0-10-stable-eager_load' into 0-10-stable
2 parents fce8be0 + 65313b9 commit 506636a

File tree

4 files changed

+40
-28
lines changed

4 files changed

+40
-28
lines changed

lib/active_model/serializer.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ class Serializer
1818
# @see #serializable_hash for more details on these valid keys.
1919
SERIALIZABLE_HASH_VALID_KEYS = [:only, :except, :methods, :include, :root].freeze
2020
extend ActiveSupport::Autoload
21-
autoload :Adapter
22-
autoload :Null
23-
autoload :Attribute
24-
autoload :Association
25-
autoload :Reflection
26-
autoload :SingularReflection
27-
autoload :CollectionReflection
28-
autoload :BelongsToReflection
29-
autoload :HasOneReflection
30-
autoload :HasManyReflection
21+
eager_autoload do
22+
autoload :Adapter
23+
autoload :Null
24+
autoload :Attribute
25+
autoload :Association
26+
autoload :Reflection
27+
autoload :BelongsToReflection
28+
autoload :HasOneReflection
29+
autoload :HasManyReflection
30+
end
3131
include ActiveSupport::Configurable
3232
include Caching
3333

lib/active_model_serializers.rb

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,19 @@
55
require 'active_support/json'
66
module ActiveModelSerializers
77
extend ActiveSupport::Autoload
8-
autoload :Model
9-
autoload :Callbacks
10-
autoload :Deserialization
11-
autoload :SerializableResource
12-
autoload :Logging
13-
autoload :Test
14-
autoload :Adapter
15-
autoload :JsonPointer
16-
autoload :Deprecate
17-
autoload :LookupChain
8+
eager_autoload do
9+
autoload :Model
10+
autoload :Callbacks
11+
autoload :SerializableResource
12+
autoload :SerializationContext
13+
autoload :Logging
14+
autoload :Test
15+
autoload :Adapter
16+
autoload :JsonPointer
17+
autoload :Deprecate
18+
autoload :LookupChain
19+
autoload :Deserialization
20+
end
1821

1922
class << self; attr_accessor :logger; end
2023
self.logger = ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new(STDOUT))
@@ -46,6 +49,11 @@ def self.silence_warnings
4649
$VERBOSE = original_verbose
4750
end
4851

52+
def self.eager_load!
53+
super
54+
ActiveModel::Serializer.eager_load!
55+
end
56+
4957
require 'active_model/serializer/version'
5058
require 'active_model/serializer'
5159
require 'active_model/serializable_resource'

lib/active_model_serializers/adapter/json_api.rb

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,16 @@ module ActiveModelSerializers
2222
module Adapter
2323
class JsonApi < Base
2424
extend ActiveSupport::Autoload
25-
autoload :Jsonapi
26-
autoload :ResourceIdentifier
27-
autoload :Relationship
28-
autoload :Link
29-
autoload :PaginationLinks
30-
autoload :Meta
31-
autoload :Error
32-
autoload :Deserialization
25+
eager_autoload do
26+
autoload :Jsonapi
27+
autoload :ResourceIdentifier
28+
autoload :Link
29+
autoload :PaginationLinks
30+
autoload :Meta
31+
autoload :Error
32+
autoload :Deserialization
33+
autoload :Relationship
34+
end
3335

3436
def self.default_key_transform
3537
:dash

lib/active_model_serializers/railtie.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
module ActiveModelSerializers
77
class Railtie < Rails::Railtie
8+
config.eager_load_namespaces << ActiveModelSerializers
9+
810
config.to_prepare do
911
ActiveModel::Serializer.serializers_cache.clear
1012
end

0 commit comments

Comments
 (0)