Imagine i have some resource objects with a run method, which executes the block parameter under the lock held for that resource. For example, like this:
r = Resource("/tmp/foo")
r.run { ... }
How can I write a ruby method which takes an array of resources and executes its block parameter under the lock held for all resources, like:
def using_resources(*res, &block)
r[0].run do; r[1].run do; r[2].run do ...
yield;
end; end; end; ...
end
Is it possible at all?