我试图从另一个thor类调用thor类。
class Foo < Thor
desc "hello", "some description"
def hello
puts "Hello from Foo class"
end
end
class Bar < Thor
desc "hello", "some description"
def hello
puts "Hello from Bar class"
# ==> HERE I WANT TO CALL HELLO FROM FOO CLASS <==
end
end有invoke方法,但是要在同一个类中调用方法。有什么办法可以做跨阶层的吗?我假设正确的方式将使用Thor框架。
编辑
我正在尝试有一个类将任务委托给其他类。例如,调用foo bar list,并将主类Foo委托给带方法列表的Bar类或foo module find 1,并使用方法查找和参数1跳转到Module。
发布于 2012-07-30 12:33:03
https://stackoverflow.com/questions/11720758
复制相似问题