### Home Classes Methods

### In Files

- lib/prawn/document/snapshot.rb

### Methods

- #rollback
- #transaction

### Files

- COPYING
- GPLv2
- GPLv3
- LICENSE

### Class/Module Index

Quicksearch

- Prawn
- Prawn::Core
- Prawn::Core::Page
- Prawn::Core::Page::GraphicsState
- Prawn::Core::Reference
- Prawn::Document
- Prawn::Document::BoundingBox
- Prawn::Document::ColumnBox
- Prawn::Document::GraphicsState
- Prawn::Document::Grid
- Prawn::Document::Internals
- Prawn::Document::PageGeometry
- Prawn::Document::Security
- Prawn::Document::Snapshot
- Prawn::Encoding
- Prawn::Errors
- Prawn::Font
- Prawn::Font::AFM
- Prawn::Font::DFont
- Prawn::Font::TTF
- Prawn::GraphicState
- Prawn::GraphicStateStack
- Prawn::Graphics
- Prawn::Graphics::CapStyle
- Prawn::Graphics::Color
- Prawn::Graphics::Dash
- Prawn::Graphics::Gradient
- Prawn::Graphics::JoinStyle
- Prawn::Graphics::Transformation
- Prawn::Graphics::Transparency
- Prawn::Images
- Prawn::Images::JPG
- Prawn::Images::PNG
- Prawn::Layout
- Prawn::Measurements
- Prawn::Outline
- Prawn::Stamp
- Prawn::Table
- Prawn::Table::Cell
- Prawn::Table::Cell::InTable
- Prawn::Table::Cell::Subtable
- Prawn::Table::Cell::Text
- Prawn::Table::Cells
- Prawn::Text
- Prawn::Text::Box
- Prawn::Text::Formatted
- Prawn::Text::Formatted::Box
- Prawn::Text::Formatted::Fragment
- Prawn::Text::Formatted::Parser
- Arcfour
- 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.