Ruby on rails Thor中的跨类调用

Ruby on rails Thor中的跨类调用,ruby-on-rails,ruby,rubygems,thor,Ruby On Rails,Ruby,Rubygems,Thor,我试图从另一个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 WAN

我试图从另一个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
class Foo#==>这里我想从FOO类中调用HELLO我从未使用过Thor,但我认为通过查看这里的规范

是的

Foo.new.invoke(:hello)

有没有一个Thor特定的原因让你不能把这个方法放在超类中?否则,您将需要一个实例,或者正如您所说,可能有一种Thor方法不必遵循正常的Ruby语义/用法。上面添加了更多信息,重点是我有很多Thor类,我想给它们一个prefix命令。它将转到这个主类并委托给其他类。我想知道是否有像托尔那样的练习可以做到这一点。