Class: Mocktail::GrabsOriginalMethodParameters

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/mocktail/grabs_original_method_parameters.rb,
lib/mocktail/sorbet/mocktail/grabs_original_method_parameters.rb

Instance Method Summary collapse

Instance Method Details

#grab(method) ⇒ Object

Sorbet wraps the original method in a sig wrapper, so we need to unwrap it. The value returned from ‘owner.instance_method(method_name)` does not have the real parameters values available, as they’ll have been erased

If the method isn’t wrapped by Sorbet, this will return the #instance_method, per usual



12
13
14
15
16
17
18
19
20
# File 'lib/mocktail/grabs_original_method_parameters.rb', line 12

def grab(method)
  return [] unless method

  if (wrapped_method = sorbet_wrapped_method(method))
    wrapped_method.parameters
  else
    method.parameters
  end
end