lib/evil_seed/relation_dumper.rb in evil-seed-0.1.0 vs lib/evil_seed/relation_dumper.rb in evil-seed-0.1.1
- old
+ new
@@ -1,6 +1,13 @@
# frozen_string_literal: true
+# As method ActiveRecord::Relation#in_batches is available only since ActiveRecord 5.0
+# we will backport it only for us via refinements for ActiveRecord 4.2 compatibility.
+unless ActiveRecord::Batches.instance_methods(false).include?(:in_batches)
+ require_relative 'refinements/in_batches'
+ using EvilSeed::Refinements::InBatches
+end
+
module EvilSeed
# This class performs actual dump generation for single relation and all its not yet loaded dependencies
#
# - Fetches all tuples for root (it does not instantiate AR records but it casts values to Ruby types)
# - Extracts foreign key values for all belongs_to associations