Code Explainers

Code explainers tagged #rollback

ruby
module FileResource
  # Opens a file, yields it to the caller, and guarantees the
  # handle is closed even if the block raises an exception.
  def self.open(path, mode = "r")

Guaranteeing cleanup with begin/ensure in Ruby

resource-management exception-safety blocks
Intermediate 8 steps