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

Wrapper not Ruby 3.0 keyword compatible #11

Open
noelrappin opened this issue May 4, 2023 · 0 comments
Open

Wrapper not Ruby 3.0 keyword compatible #11

noelrappin opened this issue May 4, 2023 · 0 comments

Comments

@noelrappin
Copy link

On updating a project to Ruby 3.0, I got a number of errors from InstanceMethodWrapper#wrap_method, and I think it is not properly handling keyword arguments, I think it should be something like:

  def wrap_method(original_method)
      original_class = klass
      klass.send(:define_method, original_method.name) do |*args, **kwargs, &block|
        begin
          DeadCodeDetector::InstanceMethodWrapper.unwrap_method(original_class, original_method)
        rescue StandardError => e
          if DeadCodeDetector.config.error_handler
            DeadCodeDetector.config.error_handler.call(e)
          end
        end
        method_bound_to_caller = original_method.bind(self)
        method_bound_to_caller.call(*args, **kwargs, &block)
      end
    end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant