Skip to content

Wrapper not Ruby 3.0 keyword compatible #11

@noelrappin

Description

@noelrappin

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions