我正在a third-party project做一些工作。 self.configure
块很大,包含许多with
语句,例如:
def self.configure
with 'ead' do |node|
make :resource
end
ignore 'titlepage'
with 'archdesc' do
# etc
这看起来像是以某种方式构建到方法的参数部分中的switch语句,但我以前从未见过这种语法。这里的任何人都知道发生了什么事吗?
答案 0 :(得分:1)
它只是一个采用字符串和块的方法:
它定义了XML标记处理程序:
def with(path, &block)
define_method(handler_name(path), block)
end
答案 1 :(得分:0)
这是一种将"ead"
作为参数和块的方法。