1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
module Mpeg class Transaction def initialize(scanner) @scanner = scanner @rewind_position = @scanner.pos @commit = false end def commit! @commit = true end def run(&block) block.call(self) ensure @scanner.pos = @rewind_position unless @commit end end end