I would just use a combination of command line and convention.
If a filter is specified, use it to filter data.
I assume that you specify a filter on the command line? So, you invoke the application as follows?
ruby dataprocessor.rb custom_filter
If so, you can define an “api” in which the class name should match what was passed in, just like you described in your example.
To take this one step further, could you have some logic that the CustomFilter class was looking for using ruby defined defined? , and if it was not found, look for custom_filter.rb (or any suitable options) and try downloading this file, and then try again.
This gives you great extensibility, since you can write as many filter classes as you want, drop them in your .rb files and put them where you can find them in ruby. You also do not have to have predefined constants, the only restrictions will be
- The class name must match the file name. This is an agreement in ruby, so you probably already do all this.
- it must have some predefined method, for example
do_filter method
By the way, this is very similar to what rails do for your models, and so you can just use SomeModel without always SomeModel require app/models/some_model first :-) `
Orion edwards
source share