I would like to concede in an enumerated block in order to create some kind of template test code.
Basically, I would like to do something like this (simplified):
def iterator( enumerable, &block )
iterations = enumerable.size
counter = 0
enumerable.each do |item|
counter +=1
puts "Iterating #{counter}/#{iterations}..."
yield
end
end
Then, I would like to use this method to wrap this template test code around a block that I would repeat so that I could call something like:
iterator foo do
item.slow_method
item.mundane_method
item.save
end
... and when this code is executed, I get the following log output:
Iterating 1/1234...
Iterating 2/1234...
Iterating 3/1234...
It seems that such a thing should be possible, but I could not figure out the syntax, as well as what it is called (to see it).
, OUTSIDE, , , INSIDE . , , .
, , . , , , .