In my Sinatra app, I am using a class with HTTParty as mixin.

class A
  include HTTParty
  format :json

  def fetch arguments
    get(:query => arguments)
  end
end

When I try to call the fetch (when the class instance is created inside a get block), I get the following error:

ArgumentError: tried to create Proc object without a block

When I run the get method as HTTParty.get all works fine. How I can resolve these name clashes or the problem is with something else? I'd really like to use HTTParty as a mixin, so I can set all the options once.

Thanks in advance!

I am using sinatra 1.3.2 and httparty 0.8.1.

有帮助吗?

解决方案

The get method is a class method.
Please try to the following, but I've not tried it out yet...

self.class.get
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top