Skip to content

Commit 1a6d67b

Browse files
committed
Cleanup compatible_table_definition methods
No need to use `class <<`.
1 parent 489e08d commit 1a6d67b

File tree

1 file changed

+8
-24
lines changed

1 file changed

+8
-24
lines changed

activerecord/lib/active_record/migration/compatibility.rb

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ def remove_foreign_key(to_table = nil, **options)
5050

5151
private
5252
def compatible_table_definition(t)
53-
class << t
54-
prepend TableDefinition
55-
end
53+
t.singleton_class.prepend(TableDefinition)
5654
super
5755
end
5856
end
@@ -180,9 +178,7 @@ def add_foreign_key(from_table, to_table, **options)
180178

181179
private
182180
def compatible_table_definition(t)
183-
class << t
184-
prepend TableDefinition
185-
end
181+
t.singleton_class.prepend(TableDefinition)
186182
super
187183
end
188184
end
@@ -243,9 +239,7 @@ def raise_on_if_exist_options(options)
243239

244240
private
245241
def compatible_table_definition(t)
246-
class << t
247-
prepend TableDefinition
248-
end
242+
t.singleton_class.prepend(TableDefinition)
249243
super
250244
end
251245
end
@@ -286,9 +280,7 @@ def add_reference(table_name, ref_name, **options)
286280

287281
private
288282
def compatible_table_definition(t)
289-
class << t
290-
prepend TableDefinition
291-
end
283+
t.singleton_class.prepend(TableDefinition)
292284
super
293285
end
294286
end
@@ -334,17 +326,13 @@ def add_timestamps(table_name, **options)
334326

335327
private
336328
def compatible_table_definition(t)
337-
class << t
338-
prepend TableDefinition
339-
end
329+
t.singleton_class.prepend(TableDefinition)
340330
super
341331
end
342332

343333
def command_recorder
344334
recorder = super
345-
class << recorder
346-
prepend CommandRecorder
347-
end
335+
recorder.singleton_class.prepend(CommandRecorder)
348336
recorder
349337
end
350338
end
@@ -432,9 +420,7 @@ def add_reference(table_name, ref_name, **options)
432420

433421
private
434422
def compatible_table_definition(t)
435-
class << t
436-
prepend TableDefinition
437-
end
423+
t.singleton_class.prepend(TableDefinition)
438424
super
439425
end
440426
end
@@ -486,9 +472,7 @@ def remove_index(table_name, column_name = nil, **options)
486472

487473
private
488474
def compatible_table_definition(t)
489-
class << t
490-
prepend TableDefinition
491-
end
475+
t.singleton_class.prepend(TableDefinition)
492476
super
493477
end
494478

0 commit comments

Comments
 (0)