Skip to content

[Improvement] Support for modules as handlers #6

Open
@josevalim

Description

@josevalim

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. :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions