Any ideas how to do something like this..?

I'd like to drop new parsers into a plugin-directory of my app without
making  modifications to the main app, so there would be something like:

# main.rb:
require 'plugins/*'
parsed_data = Parser.parse_data(data_goes_here)

# plugins/foo.rb:
class FooParser < Parser
  handles /^foo/
  def parse_data(data)
    data.do_something if data.match(@handles)
  end
end

# plugins/bar.rb:
class BarParser < Parser
  handles /^bar/
  def parse_data(data)
    data.do_something if data.match(@handles)
  end
end

Then if I wanted to add a new parser i would just throw it in there with
the rest. Perhaps some sort of "register_handler"-call in each plugin?
-- 
Posted via http://www.ruby-forum.com/.