I have a design problem which I can't think up an elegant solution for. I'm writing a background job in my rails app which means that my job class (MyJobClass) must inherit from a certain parent job class (ParentJobClass). My job will need to have the same methods, however the implementation of some of those methods will need to be different depending on the value of a parameter which is passed in during the instantiation of my job class.
Because MyJobClass is already inheriting from ParentJobClass I don't get how to get multiple implementations of the same method.
I was thinking of something like a conditional mixin of a module containing the specific implementations. However I'm not sure if that's a possible since it would be conditional on a parameter that's passed in during instantiation. E.g. something like...
class ParentJobClass
end
class MyJobClass < ParentJobClass
case @p1
when 'text'
include TextTips
when 'image'
include ImageTips
when 'video'
include VideoTips
end
def initialize(p1)
@p1 = p1
end
end