I have a Populater class for populating a database with random data. I would like to measure the populator's run method with the rtui progress bar. But instead of calling the progress bar object inside the Populater class, I would like to have a third class to increment the progress bar when certain methods in the Populater class are called. The code I have in mind is like this:
@populator = Populator.new
@pb = ProgressBar.new
Watcher.watch(@populator, :before, :add_record) do
@pb.subject = "Adding a record..."
@pb.inc
end
Watcher would call the watch block before executing @populator.add_record.
What's the best way to implement this?