jimson icon indicating copy to clipboard operation
jimson copied to clipboard

[Improvement] Support for modules as handlers

Open josevalim opened this issue 12 years ago • 1 comments

Today, I cannot use a module as a handler:

module MyModule
  extend Jimson::Handler
  def sum(a, b)
    a + b
  end
end

server = Jimson::Server.new(MyHandler)

The reason this fails is because the server expects the class of the object given to respond to a jimson method:

https://github.com/chriskite/jimson/blob/next/lib/jimson/server.rb#L168

A possible approach to this problem is to move this method to the instance, probably something along the lines of jimson_respond_to?. We could use the extended hook to inject this method in the instance.

If agreed, I can work on a pull request. :)

josevalim avatar Mar 07 '12 11:03 josevalim

That sounds good, I'd love to see your pull request :)

chriskite avatar Mar 14 '12 17:03 chriskite