diff --git a/lib/ams_lazy_relationships/loaders/association.rb b/lib/ams_lazy_relationships/loaders/association.rb index 355330f..eb1a0df 100644 --- a/lib/ams_lazy_relationships/loaders/association.rb +++ b/lib/ams_lazy_relationships/loaders/association.rb @@ -20,7 +20,7 @@ def initialize(model_class_name, association_name) # @param block [Proc] a block to execute when data is evaluated. # Loaded data is yielded as a block argument. def load(record, &block) - BatchLoader.for(record).batch(key: batch_key) do |records, loader| + BatchLoader.for(record).batch(key: batch_key, replace_methods: false) do |records, loader| data = load_data(records, loader) block&.call(data) diff --git a/lib/ams_lazy_relationships/loaders/direct.rb b/lib/ams_lazy_relationships/loaders/direct.rb index c9fe5da..341ddee 100644 --- a/lib/ams_lazy_relationships/loaders/direct.rb +++ b/lib/ams_lazy_relationships/loaders/direct.rb @@ -19,7 +19,7 @@ def initialize(relationship_name, &load_block) # @param block [Proc] a block to execute when data is evaluated. # Loaded data is yielded as a block argument. def load(record, &block) - BatchLoader.for(record).batch(key: cache_key(record)) do |records, loader| + BatchLoader.for(record).batch(key: cache_key(record), replace_methods: false) do |records, loader| data = [] records.each do |r| value = calculate_value(r) diff --git a/lib/ams_lazy_relationships/loaders/simple_belongs_to.rb b/lib/ams_lazy_relationships/loaders/simple_belongs_to.rb index 8b59567..0fe237b 100644 --- a/lib/ams_lazy_relationships/loaders/simple_belongs_to.rb +++ b/lib/ams_lazy_relationships/loaders/simple_belongs_to.rb @@ -23,7 +23,7 @@ def initialize( # @param block [Proc] a block to execute when data is evaluated # Loaded data is yielded as a block argument. def load(record, &block) - BatchLoader.for(record).batch(key: cache_key(record)) do |records, loader| + BatchLoader.for(record).batch(key: cache_key(record), replace_methods: false) do |records, loader| data = load_data(records) block&.call(data) diff --git a/lib/ams_lazy_relationships/loaders/simple_has_many.rb b/lib/ams_lazy_relationships/loaders/simple_has_many.rb index dbc0424..f8e3d8d 100644 --- a/lib/ams_lazy_relationships/loaders/simple_has_many.rb +++ b/lib/ams_lazy_relationships/loaders/simple_has_many.rb @@ -20,7 +20,7 @@ def initialize(association_class_name, foreign_key:) # Loaded data is yielded as a block argument. def load(record, &block) key = "#{record.class}/#{association_class_name}" - BatchLoader.for(record).batch(key: key) do |records, loader| + BatchLoader.for(record).batch(key: key, replace_methods: false) do |records, loader| data = load_data(records) block&.call(data)