提交 28d05f0a 编写于 作者: A Aaron Patterson

use method_defined? to check whether or not a method is defined

上级 81d08abc
......@@ -34,7 +34,7 @@ def self.name
# end
def test(name, &block)
test_name = "test_#{name.gsub(/\s+/,'_')}".to_sym
defined = instance_method(test_name) rescue false
defined = method_defined? test_name
raise "#{test_name} is already defined in #{self}" if defined
if block_given?
define_method(test_name, &block)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册