Remapping design issue
        Posted  
        
            by Sirupsen
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Sirupsen
        
        
        
        Published on 2010-05-12T08:39:23Z
        Indexed on 
            2010/05/12
            8:44 UTC
        
        
        Read the original article
        Hit count: 321
        
Hello,
I'm currently developing a Ruby Gem and I'm a bit lost on the design currently.
Basically, I'm remapping some APIs, so my skeleton is something like this:
module MyApp
  module SomeApi
    class Function > Base::Function
      ...
    end
    class Function2 > Base::Function2
      ...
    end
    ...
  end
  module SomeApi2
    ...
  end
  class RemappedFunction
    def initalize
      # set some values and stuf
      ...
    end
    def remapped_method
      # Problem:
      # How would I know, if I should take contact to
      # SomeApi, or SomeApi2?
    end
  end
  def interact_with(api)
    # What would be the best way of letting RemappedFunction
    # know which API to use?
  end
end
someapi2 = MyApp.interact_with(:someapi2)
someapi2.remapped_method
Any ideas?
© Stack Overflow or respective owner