From 50f0775b1dfbb2929c8014ab1f0e2733561632fb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20Lipski?= <michal.lipski@brandwatch.com>
Date: Thu, 22 Feb 2024 13:51:16 +0100
Subject: [PATCH] Fix a compatibility issue with active_support Object#with
 monkey patching

---
 lib/dry/effects/initializer.rb | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/dry/effects/initializer.rb b/lib/dry/effects/initializer.rb
index 5831d6e..af25562 100644
--- a/lib/dry/effects/initializer.rb
+++ b/lib/dry/effects/initializer.rb
@@ -17,7 +17,7 @@ def param(*)
         # @api private
         def option(*)
           super.tap do
-            __define_with__ unless method_defined?(:with)
+            __define_with__ unless with_method_defined?
             @has_options = true
           end
         end
@@ -48,7 +48,7 @@ def __define_with__
 
           seq_names << ", " unless seq_names.empty?
 
-          undef_method(:with) if method_defined?(:with)
+          undef_method(:with) if with_method_defined?
 
           class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
             def with(**new_options)                                    # def with(**new_options)
@@ -60,6 +60,10 @@ def with(**new_options)                                    # def with(**new_opti
             end                                                        # end
           RUBY
         end
+
+        def with_method_defined?
+          (instance_methods - superclass.instance_methods).include?(:with)
+        end
       end
 
       # @api private