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

Fix a compatibility issue with active_support Object#with monkey patching #90

Closed
wants to merge 1 commit into from
Closed
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
8 changes: 6 additions & 2 deletions lib/dry/effects/initializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down
Loading