0

I have something like this:

case method
when :get    
   HTTParty.get(configuration.endpoint)
when :post
   HTTParty.post(configuration.endpoint)
when :put
   HTTParty.put(configuration.endpoint)
end

How to do this?

HTTParty.{method}(configuration.endpoint)
Ricardo
  • 159
  • 1
  • 2
  • 9

1 Answers1

0

You can use public_send ruby method

HTTParty.public_send(method)

or with argument(s)

HTTParty.public_send(method, arg1, arg2)

Documentation of public_send method here

Gearnode
  • 693
  • 7
  • 21