トールタスクを実行するときに、特定のタスクを最初に呼び出すことはできますか?
私のトールファイル:
class Db < Thor
desc "show_Version", "some description ..."
def show_version # <= needs a database connection
puts ActiveRecord::Migrator.current_version
end
private
def connect_to_database # <= call this always when a task from this file is executed
# connect here to database
end
end
すべてのタスクで「connect_to_database」メソッドを記述できますが、それはあまり DRY ではないようです。