2012-07-30 20 views
0

我正試圖從另一個類中調用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 

有調用方法,但要調用同一類中的方法。有沒有辦法做這個跨班級?我假設正確的方式會使用Thor框架。

編輯

我想有一個類,委託任務的其他類。例如,您可以撥打foo bar list,並將主類Foo委託給Bar類的方法列表,或foo module find 1,並使用方法查找和參數1向模塊類進行解析。

+0

有沒有你不能把該方法在超雷神特有的原因是什麼?否則,你需要一個實例,或者像你說的那樣,Thor-Way不必遵循普通的Ruby語義/用法。 – 2012-07-30 12:28:21

+0

在上面添加了更多信息,指出是我有很多thor類,我想給它們前綴命令。哪個會去這個主要類並委託給其他人。我想知道是否有雷神像練習這樣做。 – 2012-07-30 13:02:35

回答