From 6c1ed873f1797a0771205c3570499cd6983ffc31 Mon Sep 17 00:00:00 2001 From: Nikita Shilnikov Date: Fri, 15 Mar 2024 15:01:23 +0100 Subject: [PATCH] Remove existing `with` when mixing in Initializer (closes #684, #687) So that it doesn't clash with the new "feature" from AS, namely, Object#with --- lib/rom/initializer.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/rom/initializer.rb b/lib/rom/initializer.rb index b5d340369..6af3154d4 100644 --- a/lib/rom/initializer.rb +++ b/lib/rom/initializer.rb @@ -47,9 +47,13 @@ def with(**new_options) # @api private def self.extended(base) - base.extend(Dry::Initializer[undefined: false]) - base.extend(DefineWithHook) - base.include(InstanceMethods) + base.module_eval do + undef_method(:with) if method_defined?(:with) + + extend(Dry::Initializer[undefined: false]) + extend(DefineWithHook) + include(InstanceMethods) + end end # @api private