我有很多这样的方法:
with_this do
with_that do
and_in_this_context do
yield
end
end
end
我记得有一个技巧可以递归地包装这样的块调用。如何编写一个为我执行块包装的方法?
def in_nested_contexts(&blk)
contexts = [:with_this, :with_that, :and_in_this_context]
# ... magic probably involving inject
end