From 7857378d31cb10afd53b3972bf4cde40464cd678 Mon Sep 17 00:00:00 2001 From: Darshana Venkatesh Date: Fri, 13 Dec 2024 14:05:51 -0800 Subject: [PATCH] removed redefine load_async warning --- lib/mongoid/contextual.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/mongoid/contextual.rb b/lib/mongoid/contextual.rb index fe0024be7e..e54a1c921f 100644 --- a/lib/mongoid/contextual.rb +++ b/lib/mongoid/contextual.rb @@ -23,7 +23,7 @@ module Contextual # The methods in the contexts themselves should all get delegated to, # including destructive, modification, and optional methods. - def_delegators :context, *(Mongo.public_instance_methods(false) - [ :skip, :limit ]) + def_delegators :context, *(Mongo.public_instance_methods(false) - [ :skip, :limit, :load_async ]) # This gets blank and empty included. def_delegators :context, *Queryable.public_instance_methods(false) @@ -47,7 +47,11 @@ def context # # @return [ Criteria ] Returns self. def load_async - context.load_async if context.respond_to?(:load_async) + if context.respond_to?(:load_async) + context.load_async + else + Mongo.instance_method(:load_async).bind(context).call + end self end