Answer the question
In order to leave comments, you need to log in
How to properly design a class hierarchy for periodic tasks of various types?
Good afternoon.
It is required to create a base class, let's call it CronTask (that is, a task that will be scheduled) and then there will be many descendants that will implement their tasks, but the base class must run all active tasks.
class CronTask
class << self
def run_all
descendants.select{|a| a.active?}.each{|a| a.run}
end
end
end
class SpecialTask << CronTask
def self.run
p 'special task'
end
end
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question