
[英]Ruby on Rails and angularJS: Can someone explain the usage and syntax pls
[英]Can someone provide an example of Thor::HiddenTask usage?
我刚刚开始使用Thor。 我一直在寻找文档,找不到隐藏任务的任何代码示例。 我想要的是这样的东西
desc "configure", "Do the configuration"
def configure
# configuration
end
desc "import", "Import the stuff"
invoke :configure
# import the stuff
end
但是我不希望配置显示在任务列表中。 有点...私人的,你知道吗? 有人可以给我一个例子吗?
在lib / thor / task.rb中,有一个Task的子类,称为HiddenTask。 谁能提供一个有关如何使用该子类以及如何hidden?
其方法的示例hidden?
被叫? 谢谢!
编辑:以下两个答案均实现了我的问题中提到的目标,但它们都不是Thor:HiddenTask用法的示例。 我想我不会接受这个问题的答案。 它们都是很好的答案,也是我实际上用来实现所需行为的第一个答案,但是我真的很想看看一个HiddenTask的示例,以便答案很好地与问题相对应。
谢谢!
在thor / spec / fixtures / script.thor中,您可以找到这样的用法:
desc "hidden TYPE", "this is hidden", :hide => true
def hidden(type)
[type]
end
这有点晚了,但也许可以帮上忙。 将您的私有方法放在“ no_task”块中,例如:
no_task do
def my_private_method
# Do something here
end
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.