@@ -93,25 +93,21 @@ class Preloader # :nodoc:
93
93
# associations before querying the database. This can save database
94
94
# queries by reusing in-memory objects. The optimization is only applied
95
95
# to single associations (i.e. :belongs_to, :has_one) with no scopes.
96
- def initialize ( associate_by_default : true , **kwargs )
97
- if kwargs . empty?
98
- ActiveSupport ::Deprecation . warn ( "Calling `Preloader#initialize` without arguments is deprecated and will be removed in Rails 7.0." )
99
- else
100
- @records = kwargs [ :records ]
101
- @associations = kwargs [ :associations ]
102
- @scope = kwargs [ :scope ]
103
- @available_records = kwargs [ :available_records ] || [ ]
104
- @associate_by_default = associate_by_default
96
+ def initialize ( records :, associations :, scope : nil , available_records : [ ] , associate_by_default : true )
97
+ @records = records
98
+ @associations = associations
99
+ @scope = scope
100
+ @available_records = available_records || [ ]
101
+ @associate_by_default = associate_by_default
105
102
106
- @tree = Branch . new (
107
- parent : nil ,
108
- association : nil ,
109
- children : associations ,
110
- associate_by_default : @associate_by_default ,
111
- scope : @scope
112
- )
113
- @tree . preloaded_records = records
114
- end
103
+ @tree = Branch . new (
104
+ parent : nil ,
105
+ association : nil ,
106
+ children : @associations ,
107
+ associate_by_default : @associate_by_default ,
108
+ scope : @scope
109
+ )
110
+ @tree . preloaded_records = @records
115
111
end
116
112
117
113
def empty?
@@ -124,12 +120,6 @@ def call
124
120
loaders
125
121
end
126
122
127
- def preload ( records , associations , preload_scope = nil )
128
- ActiveSupport ::Deprecation . warn ( "`preload` is deprecated and will be removed in Rails 7.0. Call `Preloader.new(kwargs).call` instead." )
129
-
130
- Preloader . new ( records : records , associations : associations , scope : preload_scope ) . call
131
- end
132
-
133
123
def branches
134
124
@tree . children
135
125
end
0 commit comments