I was going to make the exact same request today too. Use a class per framework. :+1:

On 8 Mar 2013, at 07:24, Brandon Hilkert <notifications@github.com> wrote:

> In lib/sidekiq/framework.rb:
> 
> > @@ -0,0 +1,67 @@
> > +module Sidekiq
> > +  module Framework
> > +    def self.which_is_it?(path='.')
> > +      if is_padrino?(path)
> > +        :padrino
> > +      elsif is_rails?(path)
> > +        :rails
> > +      elsif is_sinatra?(path)
> > +        :sinatra
> > +      end
> > +    end
> > +
> > +    def self.hook!(path)
> > +      case @framework ||= which_is_it?(path)
> There's a lot of conditionals in this file. Seems like a perfect use case for polymorphism. You've already setup individual modules for each framework, and it seems logical to extend that even further. It may require making them classes instead of modules. For instance....
> 
> I think you could also take it a step further and implement some simple delegation on the frameworks, so as long as you keep the method name the same between this class and the sub-framework classes.
> 
> If when you first get the framework, you figure out which one it is in the constructor:
> 
> module Sidekiq
>   class Framework
>      def initialize
>         @framework = identify_framework.new
>      end
> 
>      def hook!
>         @framework.hook # All Framework classes respond to hook, and you can do all the correct requires in it
>      end
> 
>      def root
>         @framework.root # All Framework classes respond to root, and do the right thing
>      end
> 
>      private
> 
>      def identify_framework
>         ..... #you logic to figure out which one, ie let's assume it's Rails
>         Sidekiq::Framework::Rails
>      end
>    end
> end
> None of this is totally necessary, but it would keep the complication out of this class and make some beautiful code  
> 
> —
> Reply to this email directly or view it on GitHub.