0
在Sinatra
寶石有production?
和development?
功能, 如何檢查腳本是有史以來需要Sinatra
或者有production?
和development?
函數曾經定義?如何檢查是否一個Ruby的功能(不是方法)存在
可能是更好的解釋:
script1.rb:
# there is possibility that this script contains "require 'sinatra'"
# note that sinatra defines 'production?' and 'development?' function
script2.rb:
# there is possibility that this script already has defining 'production?' function
script3.rb:
require_relative 'script1'
require_relative 'script2'
...
require_relative 'scriptX'
# in this script, how to know if there are at least one script that has already defining 'production?' function?
你調用的函數實際上是方法。 – 2014-11-21 03:06:43
'對象'的方法? – Kokizzu 2014-11-21 03:08:25
Ruby中沒有函數,只有實例方法。你能澄清你的問題嗎?你在說「Proc」嗎? – 2014-11-21 10:39:34