I want to have named parameters for the method, so the API is clear to the caller, but to implement the method, you need named parameters in the hash. So I have this:
def my_method(required_param, named_param_1: nil, named_param_2: nil)
named_params = {
named_param_1: named_param_1,
named_param_2: named_param_2
}
end
This works, but I have to do it in several places, and I would rather have a helper that dynamically gets named parameters to the hash. I could not find a way to do this. Any thoughts on how to do this?
source
share