Creating a generic function for objects of different classes How might I refactor this to get rid of all the if-else?

  def self.dispatches_for(object)
    scope = Dispatch.asc(:days)
    if object.class == Habit
      scope.where(:habit=&gt;object).map{|d|d}
    elsif object.class == User
      scope.where(:coach=&gt;object).map{|d|d}
    elsif object.class == Content
      scope.where(:content=&gt;object).map{|d|d}
    end
  end
def self.dispatches_for(object)
  klass = object.class.to_s.downcase.to_sym
  raise "unacceptable class" unless klass.in? [:habit, :coach, :content]
  scope = Dispatch.asc(:days)
  scope.where(klass=&gt;object).map{|d|d}
end