Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Object#with conflict with ActiveSupport 7.1 #687

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions core/lib/rom/initializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ module ROM
module Initializer
# @api private
module DefineWithHook
# Prevent interference from Object#with from
# ActiveSuport 7.1 core extensions.
#
# @api private
def self.extended(klass)
klass.define_method(:with) {}
klass.undef_method(:with)
end

# @api private
def param(*)
super.tap { __define_with__ }
Expand Down
9 changes: 9 additions & 0 deletions core/lib/rom/pipeline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ def map_with(*names)
#
# @api private
module Proxy
# Prevent interference from Object#with from
# ActiveSuport 7.1 core extensions.
#
# @api private
def self.included(klass)
klass.define_method(:with) {}
klass.undef_method(:with)
end

# @api private
def respond_to_missing?(name, include_private = false)
left.respond_to?(name) || super
Expand Down
9 changes: 9 additions & 0 deletions core/spec/support/method_interference.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

# This mocks Object#with to simulate ActiveSupport 7.1
# whose definition of #with caused interference
class Object
def with(*args, **kwargs, &block)
Kernel.raise("Object#with conflict")
end
end