2015-10-19 48 views
3

在我的Guardfile中,我有這種奇怪的方法調用語法rspec.spec.("requests/#{m[1]}")。雖然這完美的作品,我不明白是什麼方法實際上被稱爲。在沒有方法名稱的情況下使用ruby進行調用

此語法是否有名稱或術語?

guard :rspec, cmd: "bundle exec rspec" do 

    # ... 
    watch(rails.controllers) do |m| 
    [ 
     rspec.spec.("routing/#{m[1]}_routing"), 
     rspec.spec.("controllers/#{m[1]}_controller"), 
     rspec.spec.("requests/#{m[1]}") 
    ] 
    end 
end 
+0

感謝@Drenmi,我想不出一個恰當的搜索詞組。它是重複的。 – max

+0

沒問題@max。由於缺乏方法名稱,需要進行一些搜索。 :-) – Drenmi

回答

3

嘗試:

foo = "Foo" 
foo.("a") 
# NoMethodError: undefined method `call' for "Foo":String 

routine = Proc.new { |arg| puts "Hello #{arg}!" } 
routine.("world") 
# Hello world! 
相關問題