### Home Classes Methods

### In Files

- lib/prawn/document/snapshot.rb

### Methods

- #rollback
- #transaction

### Files

- COPYING
- HACKING
- LICENSE
- README

### Class/Module Index

Quicksearch

- Prawn
- Prawn::Core
- Prawn::Document
- Prawn::Document::Annotations
- Prawn::Document::BoundingBox
- Prawn::Document::ColumnBox
- Prawn::Document::Destinations
- Prawn::Document::GraphicsState
- Prawn::Document::Internals
- Prawn::Document::PageGeometry
- Prawn::Document::Snapshot
- Prawn::Encoding
- Prawn::Errors
- Prawn::Font
- Prawn::Font::AFM
- Prawn::Font::DFont
- Prawn::Font::TTF
- Prawn::Graphics
- Prawn::Graphics::CapStyle
- Prawn::Graphics::Color
- Prawn::Graphics::Dash
- Prawn::Graphics::JoinStyle
- Prawn::Graphics::Transformation
- Prawn::Graphics::Transparency
- Prawn::Images
- Prawn::Images::JPG
- Prawn::Images::PNG
- Prawn::Measurements
- Prawn::Outline
- Prawn::Stamp
- Prawn::Text
- Prawn::Text::Box
- Prawn::Text::LineWrap
- File
- Numeric

No matching classes.

# Prawn::Document::Snapshot

### Constants

RollbackTransaction

### Public Instance Methods

rollback() click to toggle source

Call this within a `transaction` block to roll back the transaction and prevent any of its data from being rendered. You must reset the y-position yourself if you have performed any drawing operations that modify it.

    # File lib/prawn/document/snapshot.rb, line 21
    def rollback
      raise RollbackTransaction
    end

transaction() click to toggle source

Run a block of drawing operations, to be completed atomically. If `rollback` is called or a RollbackTransaction exception is raised inside the block, all actions taken inside the block will be rolled back (with the exception of y-position, which you must restore yourself).

Returns true on success, or false if the transaction was rolled back.

    # File lib/prawn/document/snapshot.rb, line 33
    def transaction
      snap = take_snapshot
      yield
      true
    rescue RollbackTransaction
      restore_snapshot(snap)
      false
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.